From 1ebe52ee3c425650b660a1f7f8836d5e7c06e41f 2014-03-08 01:48:34 From: Paul Ivanov Date: 2014-03-08 01:48:34 Subject: [PATCH] added new use_shortcut method to shortcuts this way, you can ask if a particular event will be handled by the shortcuts system. This takes away the need to special-case many different possible keys which should be ignored by codemirror by ignoring them en masse. --- diff --git a/IPython/html/static/base/js/keyboard.js b/IPython/html/static/base/js/keyboard.js index 20e38ba..c009d60 100644 --- a/IPython/html/static/base/js/keyboard.js +++ b/IPython/html/static/base/js/keyboard.js @@ -237,6 +237,12 @@ IPython.keyboard = (function (IPython) { return true; } + ShortcutManager.prototype.use_shortcut = function (event) { + var shortcut = event_to_shortcut(event); + var data = this._shortcuts[shortcut]; + return !( data === undefined ) + } + return { keycodes : keycodes, inv_keycodes : inv_keycodes, diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index 994f643..469e6a2 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -169,7 +169,11 @@ var IPython = (function (IPython) { */ Cell.prototype.handle_codemirror_keyevent = function (editor, event) { var that = this; + var shortcuts = IPython.keyboard_manager.edit_shortcuts; + // if this is an edit_shortcuts shortcut, we've already handled it. + if (shortcuts.use_shortcut(event)) { return true; } + if (event.keyCode === keycodes.enter && (event.shiftKey || event.ctrlKey || event.altKey)) { // Always ignore shift-enter in CodeMirror as we handle it. return true;