code: def load_confirm_exit_bindings(python_input):
      
      bindings = KeyBindings()
  
      handle = bindings.add
      confirmation_visible = Condition(lambda: python_input.show_exit_confirmation)
  
      @handle('y', filter=confirmation_visible)
      @handle('Y', filter=confirmation_visible)
      @handle('enter', filter=confirmation_visible)
      @handle('c-d', filter=confirmation_visible)
      def _(event):
          """
          Really quit.
          """
          event.app.exit(exception=EOFError, style='class:exiting')
  
      @handle(Keys.Any, filter=confirmation_visible)
      def _(event):
          """
          Cancel exit.
          """
          python_input.show_exit_confirmation = False
  
      return bindings
docs: Handle yes/no key presses when the exit confirmation is shown.