【发布时间】:2023-04-02 10:53:01
【问题描述】:
我的一个 Jupyter 笔记本使用 html <input> 标记,该标记需要输入的用户输入,但每当我在文本框中输入时,命令模式键盘快捷键就会激活。
是否可以关闭单个单元格或笔记本的键盘快捷键?
【问题讨论】:
标签: html ipython ipython-notebook jupyter
我的一个 Jupyter 笔记本使用 html <input> 标记,该标记需要输入的用户输入,但每当我在文本框中输入时,命令模式键盘快捷键就会激活。
是否可以关闭单个单元格或笔记本的键盘快捷键?
【问题讨论】:
标签: html ipython ipython-notebook jupyter
您可以使用Jupyter.keyboard_manager.disable()暂时禁用快捷键,然后使用Jupyter.keyboard_manager.enable()重新激活。
【讨论】:
您可以将此行复制粘贴到您的 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')
...
});
或者你想删除的任何快捷方式。
来源: http://akuederle.com/customize-ipython-keymap/
如果你想要我的 github 上的示例 custom.js、this is mine。
【讨论】:
根据the current 'Customize keymaps' docuemntation,现在可以使用~/.jupyter/nbconfig/notebook.json 文件比hlin117 的回答更简单:
例如,要取消绑定在光标位置拆分单元格的快捷方式(Ctrl-Shift-Minus),请使用以下命令:
// file ~/.jupyter/nbconfig/notebook.json
{
"keys": {
"edit": {
"unbind": [
"Ctrl-Shift-Minus"
]
},
},
}
【讨论】: