简体   繁体   中英

Disable Jupyter Keyboard Shortcuts

One of my Jupyter notebooks uses an html <input> tag that expects typed user input, but whenever I type in the text box, command mode keyboard shortcuts activate.

Is it possible to turn off keyboard shortcuts for a single cell or notebook?

您可以使用Jupyter.keyboard_manager.disable()暂时禁用快捷方式,并使用Jupyter.keyboard_manager.enable()再次激活。

You could copy paste this line into your custom.js:

$([IPython.events]).on("app_initialized.NotebookApp", function () {
    ...
    // Starting from this line, replace 'Shift-k' with whatever 
    // shortcut you're trying to remove.
    IPython.keyboard_manager.command_shortcuts.remove_shortcut('Shift-k')
    ...
});

Or whatever shortcut you wish to remove.

Source: http://akuederle.com/customize-ipython-keymap/

If you want a sample custom.js , this is mine on my github.

As per the current 'Customize keymaps' docuemntation , this can now be done using the ~/.jupyter/nbconfig/notebook.json file more simply than hlin117 's answer:

For example, to unbind the shortcut to split a cell at the position of the cursor (Ctrl-Shift-Minus)use the following:

// file ~/.jupyter/nbconfig/notebook.json
{
  "keys": {
    "edit": {
      "unbind": [
        "Ctrl-Shift-Minus"
      ]
    },
  },
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM