jupyterlab/jupyterlab-toc

Keyboard shortcut to show sidebar panel?

longouyang opened this issue · 1 comments

Hi there - thanks so much for writing this extension, it's incredibly helpful for navigating large notebooks.

I've searched a bit but can't find any direct resources on this - is it possible to bind a keyboard shortcut to directly open/close the TOC panel in the left sidebar?

Actually, I figured it by understanding jupyterlab internals a bit better.

For anyone else that might want this, you can add this keyboard shortcut setting:

{
            "command": "tabsmenu:activate-by-id",
            "args": {
                "id": "table-of-contents"
            },
            "keys": [
                "Alt Shift 1"
            ],
            "selector": "body"  
}

This will bind alt+shift+1 to showing the TOC.

Here's how this works - jupyterlab creates the left sidebar icon using the "front-end shell" and gives it the id table-of-contents. There's a "command" called tabsmenu:activate-by-id that programatically opens icons given ids.