ILoveCoding
ILoveCoding

Reputation: 916

jupyterlab keyboardshortcuts: Which selector to use

I'm trying to set 3 keyboards shortcuts in jupyterlab. I go about this via settings / advanced settings editor / keyboard shortcuts, that's the only method I'm aware of. I'm trying to set:

notebook:run-all-cells
notebook:run-all-above
notebook:run-all-below

I've experimented with the selectors that work for restart-and-clear: "selector": "[data-jp-kernel-user]:focus" and several others, not really understanding what they were to be honest, but I couldn't get it to work. Can someone tell me which selector I need to use here? How does one go about figuring this out?

Thanks

Upvotes: 0

Views: 722

Answers (1)

krassowski
krassowski

Reputation: 15379

Since you are trying to run cells, presumably having one of the cells selected, I would use [data-jp-code-runner], for example:

{
    "command": "notebook:run-all-cells",
    "keys": ["F9"],
    "selector": "[data-jp-code-runner]"
}

To discover a selector in the future you can search the list of existing shortcuts in the left panel. for example searching for Shift Enter or run keyword brings up:

        {
            "command": "runmenu:run",
            "keys": [
                "Shift Enter"
            ],
            "selector": "[data-jp-code-runner]"
        },

Alternatively you could:

  • use just body if you want the shortcut to be always active (even though it may error if executed when focus is not on appropriate element)
  • (advanced) use web developer inspector tool in your browser to determine the web query (CSS) selector for the element of interest

Upvotes: 1

Related Questions