diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index 22acafd..33f3b97 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -91,7 +91,7 @@ var IPython = (function (IPython) { }; - if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) { + if (event.keyCode === key.enter && (event.shiftKey || event.ctrlKey)) { // Always ignore shift-enter in CodeMirror as we handle it. return true; } else if (event.which === 40 && event.type === 'keypress' && tooltip_wait_time >= 0) { diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index 181a13f..79a3004 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -12,6 +12,7 @@ var IPython = (function (IPython) { var utils = IPython.utils; + var key = IPython.utils.keycodes; var Notebook = function (selector) { this.read_only = IPython.read_only; @@ -73,27 +74,27 @@ var IPython = (function (IPython) { that.save_notebook(); event.preventDefault(); return false; - } else if (event.which === 27) { + } else if (event.which === key.esc) { // Intercept escape at highest level to avoid closing // websocket connection with firefox event.preventDefault(); } - if (event.which === 38 && !event.shiftKey) { + if (event.which === key.upArrow && !event.shiftKey) { var cell = that.get_selected_cell(); if (cell.at_top()) { event.preventDefault(); that.select_prev(); }; - } else if (event.which === 40 && !event.shiftKey) { + } else if (event.which === key.downArrow && !event.shiftKey) { var cell = that.get_selected_cell(); if (cell.at_bottom()) { event.preventDefault(); that.select_next(); }; - } else if (event.which === 13 && event.shiftKey) { + } else if (event.which === key.enter && event.shiftKey) { that.execute_selected_cell(); return false; - } else if (event.which === 13 && event.ctrlKey) { + } else if (event.which === key.enter && event.ctrlKey) { that.execute_selected_cell({terminal:true}); return false; } else if (event.which === 77 && event.ctrlKey && that.control_key_active == false) { diff --git a/IPython/frontend/html/notebook/static/js/utils.js b/IPython/frontend/html/notebook/static/js/utils.js index a2e6f32..d7da891 100644 --- a/IPython/frontend/html/notebook/static/js/utils.js +++ b/IPython/frontend/html/notebook/static/js/utils.js @@ -97,6 +97,8 @@ IPython.utils = (function (IPython) { tab : 9, enter : 13, shift : 16, + ctrl : 17, + control : 17, esc : 27, space : 32, pgUp : 33,