Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: How to set user-defined shortcuts #405

Open
drtoche opened this issue Feb 11, 2022 · 6 comments
Open

Docs: How to set user-defined shortcuts #405

drtoche opened this issue Feb 11, 2022 · 6 comments

Comments

@drtoche
Copy link

drtoche commented Feb 11, 2022

Thanks for this great app!

Just getting started with Jupyter Lab Desktop and all the rest of it, so I may be missing something obvious.

I wanted to set my own shortcuts. Here's what I tried and it's not working:

Under the sub-menu (not the horizontal menu at the top named "JupyterLab", but the unnamed horizontal menu immediately below), I selected Settings -> Advanced Settings Editor and, following instructions, copied the following code snippet into the area named "Settings / User Preferences". I'm trying to assign the F11 key, but it doesn't work. It's sending me Full Screen mode instead.

  • Maybe the "selector" is wrong?
  • Maybe the shortcuts I need to edit are not these but the ones that belong to the top horizontal menu for JupyterLab instead?

Also I cannot find these user settings. They are supposed to be inside my environment inside @jupyterlab/shortcuts-extension, I believe, but they are not there. I'd like to back them up so I'd like to know where they are (assuming I can make them work, that is).

Thanks for your help. Please point me to the doc or, if there isn't one on this, perhaps after this is resolved we could add a few lines of explanations.

Thanks!

{
    // Keyboard Shortcuts
    // @jupyterlab/shortcuts-extension:shortcuts
    // Keyboard shortcut settings.
    // *****************************************
    // MODIFIED keyboard shortcuts:
    "shortcuts": [
        {
            "command": "notebook:run-in-console",
            "keys": [
                "F11"
            ],
            "selector": ".jp-Notebook.jp-mod-editMode"
        }
    ]
}

I'm using updated versions of Jupyter Lab Desktop and updated all my packages and am on Python 3.9 and MacOS, if that matters.

EDIT I also would like to change the command+w shortcut. When I use it, it's closing all my windows instead of the current file, as I would expect from behavior with other IDEs. Under the JupyterLab menu at the top, it is shown as "Close Window": it closes the entire window but I would like it to close single tabs (After all my windows are closed, I don't know what I'm supposed to do and I have to restart Jupyter Lab Desktop. And the default command+q shown in the JupyterLab menu at the top doesn't work, so there are several issues here.

jupyterlab-shortcuts

@welcome
Copy link

welcome bot commented Feb 11, 2022

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@krassowski
Copy link
Member

I'm trying to assign the F11 key, but it doesn't work. It's sending me Full Screen mode instead.

This is indeed a conflict with the default shortcut for full screen. This is a bug: we should be configuring this shortcut (and others) via JupyterLab settings, and not hard-code it as it is currently:

{accelerator: 'F11', command: this.toggleFullscreen.bind(this)},

It is on my agenda once we tackle more dire issues, but in the meantime community contributions are welcome.

Also I cannot find these user settings. They are supposed to be inside my environment inside @jupyterlab/shortcuts-extension, I believe, but they are not there. I'd like to back them up so I'd like to know where they are (assuming I can make them work, that is).

Could you clarify this bit? I do not understand what you are expecting and what you are struggling to find.

I also would like to change the command+w shortcut. When I use it, it's closing all my windows instead of the current file, as I would expect from behavior with other IDEs.

The following works well for me:

  {
      "command": "application:close",
      "keys": [
          "Ctrl W"
      ],
      "selector": "body"
  }

@drtoche
Copy link
Author

drtoche commented Feb 12, 2022

I see, thanks very much! :-)

I'll just wait patiently, as unfortunately I don't have the skill to contribute to a PR.

I have not reconfigured any shortcut for closing tabs or quitting and this is the behavior I observe "out of the box": CTRL+w doesn't do anything at all, CMD+w quits the app, but keeps the icon in the tray so it looks like it's still active, CMD+q doesn't do anything either.

ScreenCap

What I was looking for was a shortcut to close the currently active tab. In browsers this is typically assigned by default to CMD+w (in MacOS parlance, maybe its CTRL on Windows).

screenshot

@krassowski
Copy link
Member

What I was looking for was a shortcut to close the currently active tab. In browsers this is typically assigned by default to CMD+w (in MacOS parlance, maybe its CTRL on Windows).

Have you tried the shortcut configuration I provided? This is exactly what it is supposed to do. The name of the shortcut may seem confusing. It works well on Ubuntu, but I have not tested it on Mac where it might get intercepted. Please let me know if you tried it and what was the outcome.

BTW you can also alter tab switching behaviour with:

{
    "command": "application:activate-next-tab",
    "keys": [
        "Ctrl Tab"
    ],
    "selector": "body"
},
{
    "command": "application:activate-previous-tab",
    "keys": [
        "Ctrl Shift Tab"
    ],
    "selector": "body"
},

@drtoche
Copy link
Author

drtoche commented Feb 13, 2022

Have you tried the shortcut configuration I provided?

Oh sorry I thought you were showing the default settings.

So I copy-pasted the settings you provided into the user configuration and ⌘+w does indeed offer to "stay" or "leave". If I click on "stay", it stays as expected. If I click on "leave" it leaves, but the icon stays around as if the app hadn't really quit. (Edit: from this point, there is no way to open a file or create a new one, so it's as good as "quit", except the icon and top menu bar are still there)

If I type the escape key instead of clicking on "stay" or "leave", as would be natural to mimic a "cancel" action, the app leaves but the icon stays around.

If I click on "⌘+q" nothing happens, but if I click via the menu on "Quit Jupyterlab-desktop ⌘Q" it does quit properly, leaving no icon behind in the tray.

The code you provided to switch tabs works great! Thanks! I opted for "Alt" instead of "Ctrl", because on my MacBook the "control" key on the far left and not convenient to combine with "Tab", while there is a second "Alt" key on the right-hand side that is a lot easier to combine with "Tab".

@JasonWeill
Copy link

The "Command-W" shortcut is also mentioned in #436.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants