Disable Jupyter Keyboard Shortcuts

我们两清 提交于 2019-12-07 03:38:49

问题


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?


回答1:


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.




回答2:


You can use Jupyter.keyboard_manager.disable() to disable the shortcuts temporarily, and use Jupyter.keyboard_manager.enable() to activate again.




回答3:


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"
      ]
    },
  },
}


来源:https://stackoverflow.com/questions/34126296/disable-jupyter-keyboard-shortcuts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!