jupyterlab_code_formatter icon indicating copy to clipboard operation
jupyterlab_code_formatter copied to clipboard

Feature Request: proposal for additional keyboard shortcuts

Open lucatrv opened this issue 5 years ago • 9 comments

I have been using the following keyboard shortcuts for a while. I post them here for evaluation, I find them very convenient and I think they fit very well with the existing default shortcuts (e.g. "Alt W" for "application:close"). If agreed I can submit a PR.

{
    "shortcuts": [
        {
            "command": "runmenu:run-all",
            "keys": [
                "Alt R"
            ],
            "selector": "[data-jp-code-runner]"
        },
        {
            "command": "runmenu:restart-and-run-all",
            "keys": [
                "Ctrl Alt R"
            ],
            "selector": "[data-jp-code-runner]"
        },
                {
            "command": "jupyterlab_code_formatter:format",
            "keys": [
                "Alt F"
            ],
            "selector": ".jp-Notebook.jp-mod-editMode"
        },
        {
            "command": "jupyterlab_code_formatter:format_all",
            "keys": [
                "Ctrl Alt F"
            ],
            "selector": ".jp-Notebook.jp-mod-editMode"
        },
        {
            "command": "application:activate-next-tab",
            "keys": [
                "Alt 2"
            ],
            "selector": "body"
        },
        {
            "command": "application:activate-previous-tab",
            "keys": [
                "Alt 1"
            ],
            "selector": "body"
        },
        {
            "command": "tabsmenu:activate-previously-used-tab",
            "keys": [
                "Alt 0"
            ],
            "selector": "body"
        },
        {
            "command": "filemenu:close-and-cleanup",
            "keys": [
                "Alt Q"
            ],
            "selector": ".jp-Activity"
        }
    ]
}

lucatrv avatar Mar 20 '20 17:03 lucatrv

Hmm I feel like this is just down to personal reference, but I do think more documentation regarding the possible shortcut for format and format_all might help.

ryantam626 avatar Mar 28 '20 09:03 ryantam626

Oh unless you mean include this as the default set of keybindings instead of just documentation?

ryantam626 avatar Mar 28 '20 09:03 ryantam626

Yes, if you agree I can create a PR to add this to the default set.

lucatrv avatar Mar 28 '20 09:03 lucatrv

Do you happen to know how user can remove the default set of keybindings? If there is no such option, I would prefer us not to provide a keybinding that leads with "Alt", they usually allow users to open the browser context menu.

ryantam626 avatar Mar 28 '20 09:03 ryantam626

You can redefine the keybindings that you do not want. The default set already defines "Alt W" for "application:close". And you can still open the browser context menu with "Alt" alone. I took care not to overwrite common browser keystrokes, such as "Ctrl R", "Ctrl F", etc. As far as I know, "Alt 1" and "Alt 2" are used only by Firefox under Linux (instead of "Ctrl 1" and "Ctrl 2") to switch to tabs 1 and 2, but if you are working within Jupyter Lab it makes sense that they act on its tabs.

lucatrv avatar Mar 28 '20 11:03 lucatrv

Another option could be "Alt N" for "application:activate-next-tab", "Alt P" for "application:activate-previous-tab", and "Alt L" for "tabsmenu:activate-previously-used-tab" (last used tab).

lucatrv avatar Mar 28 '20 12:03 lucatrv

Another option could be "Alt PageDown" for "application:activate-next-tab", "Alt PageUp" for "application:activate-previous-tab", and "Alt L" for "tabsmenu:activate-previously-used-tab" (last used tab). But "PageDown" / "PageUp" don't work.

lucatrv avatar Mar 28 '20 12:03 lucatrv

Sorry I now realized that I opened this issue on the wrong repository, I am going to report this to JupyterLab, apart from "Alt F" and "Ctrl Alt F" that would remain here.

lucatrv avatar Mar 28 '20 12:03 lucatrv

...I did already in the past and forgot about it, see PR #7558. So for your evaluation is only "Alt F" and "Ctrl Alt F", maybe you want to wait the decision about PR #7558.

lucatrv avatar Mar 28 '20 12:03 lucatrv

Closing due to inactivity, just having a look again, I think these are the responbility of the end-user anyway :sweat_smile:

ryantam626 avatar May 05 '23 08:05 ryantam626