jupyterlab-emacskeys icon indicating copy to clipboard operation
jupyterlab-emacskeys copied to clipboard

Chrome captures some keybindings

Open timp0 opened this issue 6 years ago • 6 comments

This is great (as far as it goes), but I notice that many of the navigations commands (i.e. ctrl-P, ctrl-N, ctrl-F) are still captured by chrome. Ctrl-N can be solved by opening jupyterlab as an app in chrome, but ctrl-P and ctrl-F seem fixed? Do you know of any solution?

timp0 avatar Jul 30 '19 16:07 timp0

I think you could start by setting the Emacs key-theme for all GTK applications like this:

gsettings set org.gnome.desktop.interface gtk-key-theme "Emacs"

or/and editing ~/.config/gtk-3.0/settings.inilike this:

[Settings]
gtk-key-theme-name = Emacs

But you'll still need to remap some jupyterlab shortcuts. This was not a problem few months ago, but now with newer jupyterlab versions, some shortcuts like Ctrl+P and Ctrl+F seems to be used by jupyterlab.

As an example, this is how my Keyboard Shortcuts->User Preferences look like:

{
    // Keyboard Shortcuts
    // @jupyterlab/shortcuts-extension:shortcuts
    // Keyboard shortcut settings.
    // *****************************************

    "shortcuts": [
        {
            "command": "application:toggle-left-area",
            "keys": [
                "Ctrl '"
            ],
            "selector": "body"
        },
        {
            "command": "notebook:split-cell-at-cursor",
            "keys": [
                "Ctrl Alt Shift -"
            ],
            "selector": ".jp-Notebook.jp-mod-editMode"
        },
        {
            "command": "apputils:print",
            "keys":["Accel P"],
            "selector": "body",
            "disabled": true
        },
        {
            "command": "documentsearch:start",
            "keys": [
                "Accel F"
            ],
            "selector": ".jp-mod-searchable",
            "disabled": true
        },
    ]
}

kpe avatar Jul 31 '19 09:07 kpe

This is helpful thanks. So basically you have also disabled the ctrl-P and ctrl-F. I did something similar but also remapped documentsearch:start to ctrl-S.

However, it doesn't address the core issue of chrome capturing some of these commands before jupyter can get them. I'm on Win10 btw currently rather than linux, so the gtk stuff doesn't help to avoid that. Is there a best browser/browser extension that can specify (for localhost for example) not to capture any keyboard shortcuts? It seems I can disable them broadly with shortkeys extension, but even that has some problems.

timp0 avatar Jul 31 '19 12:07 timp0

I haven't use windows recently, and don't know if firefox on windows would be a better fit. There is something called xkeymacs - I haven't tried it, and it seems to be aged, but I guess something similar would be needed.

kpe avatar Jul 31 '19 12:07 kpe

Firefox (and most browsers) seem to aggressively capture ctrl-N for example. Surprisingly, you can get around this with chrome by making the webpage into an app, but it doesn't solve ctrl-P - print.

I'm currently thinking qutebrowser, webmacs or konqueror could be better because of their higher configurability - at least for the purposes of jupyter (or Rstudio for that matter)

timp0 avatar Jul 31 '19 13:07 timp0

@timp0 - somewhat out of topic - but I found using a standard development workflow (let's say proper OO, unittests, a real IDE like pycharm) could boost efficiency (check - https://www.youtube.com/watch?v=7jiPeIFXb6U).

kpe avatar Jul 31 '19 14:07 kpe

100% agree. I use notebooks for data exploration rather than actual development per se. This is why I don't want to break my emacs muscle memory to use notebooks.

timp0 avatar Jul 31 '19 14:07 timp0