##// END OF EJS Templates
Uppercase constant keycode in utils.js
Matthias BUSSONNIER -
Show More
@@ -67,13 +67,13 b' var IPython = (function (IPython) {'
67 var that = this;
67 var that = this;
68 // whatever key is pressed, first, cancel the tooltip request before
68 // whatever key is pressed, first, cancel the tooltip request before
69 // they are sent, and remove tooltip if any, except for tab again
69 // they are sent, and remove tooltip if any, except for tab again
70 if(event.type === 'keydown' && event.which != key.tab ) {
70 if (event.type === 'keydown' && event.which != key.TAB ) {
71 IPython.tooltip.remove_and_cancel_tooltip();
71 IPython.tooltip.remove_and_cancel_tooltip();
72 };
72 };
73
73
74 var cur = editor.getCursor();
74 var cur = editor.getCursor();
75
75
76 if (event.keyCode === key.enter && (event.shiftKey || event.ctrlKey)) {
76 if (event.keyCode === key.ENTER && (event.shiftKey || event.ctrlKey)) {
77 // Always ignore shift-enter in CodeMirror as we handle it.
77 // Always ignore shift-enter in CodeMirror as we handle it.
78 return true;
78 return true;
79 } else if (event.which === 40 && event.type === 'keypress' && IPython.tooltip.time_before_tooltip >= 0) {
79 } else if (event.which === 40 && event.type === 'keypress' && IPython.tooltip.time_before_tooltip >= 0) {
@@ -81,7 +81,7 b' var IPython = (function (IPython) {'
81 // browser and keyboard layout !
81 // browser and keyboard layout !
82 // Pressing '(' , request tooltip, don't forget to reappend it
82 // Pressing '(' , request tooltip, don't forget to reappend it
83 IPython.tooltip.pending(that);
83 IPython.tooltip.pending(that);
84 } else if (event.which === key.upArrow) {
84 } else if (event.which === key.UPARROW) {
85 // If we are not at the top, let CM handle the up arrow and
85 // If we are not at the top, let CM handle the up arrow and
86 // prevent the global keydown handler from handling it.
86 // prevent the global keydown handler from handling it.
87 if (!that.at_top()) {
87 if (!that.at_top()) {
@@ -90,7 +90,7 b' var IPython = (function (IPython) {'
90 } else {
90 } else {
91 return true;
91 return true;
92 };
92 };
93 } else if (event.which === key.downArrow) {
93 } else if (event.which === key.DOWNARROW) {
94 // If we are not at the bottom, let CM handle the down arrow and
94 // If we are not at the bottom, let CM handle the down arrow and
95 // prevent the global keydown handler from handling it.
95 // prevent the global keydown handler from handling it.
96 if (!that.at_bottom()) {
96 if (!that.at_bottom()) {
@@ -99,7 +99,7 b' var IPython = (function (IPython) {'
99 } else {
99 } else {
100 return true;
100 return true;
101 };
101 };
102 } else if (event.keyCode === key.tab && event.type == 'keydown') {
102 } else if (event.keyCode === key.TAB && event.type == 'keydown') {
103 // Tab completion.
103 // Tab completion.
104 //Do not trim here because of tooltip
104 //Do not trim here because of tooltip
105 var pre_cursor = editor.getRange({line:cur.line,ch:0},cur);
105 var pre_cursor = editor.getRange({line:cur.line,ch:0},cur);
@@ -118,7 +118,7 b' var IPython = (function (IPython) {'
118 this.completer.startCompletion();
118 this.completer.startCompletion();
119 return true;
119 return true;
120 };
120 };
121 } else if (event.keyCode === key.backspace && event.type == 'keydown') {
121 } else if (event.keyCode === key.BACKSPACE && event.type == 'keydown') {
122 // If backspace and the line ends with 4 spaces, remove them.
122 // If backspace and the line ends with 4 spaces, remove them.
123 var line = editor.getLine(cur.line);
123 var line = editor.getLine(cur.line);
124 var ending = line.slice(-4);
124 var ending = line.slice(-4);
@@ -227,19 +227,19 b' var IPython = (function (IPython) {'
227 var code = event.keyCode;
227 var code = event.keyCode;
228 var that = this;
228 var that = this;
229 // Enter
229 // Enter
230 if (code == key.enter) {
230 if (code == key.ENTER) {
231 CodeMirror.e_stop(event);
231 CodeMirror.e_stop(event);
232 this.pick();
232 this.pick();
233 }
233 }
234 // Escape or backspace
234 // Escape or backspace
235 else if (code == key.esc) {
235 else if (code == key.ESC) {
236 CodeMirror.e_stop(event);
236 CodeMirror.e_stop(event);
237 this.close();
237 this.close();
238 this.editor.focus();
238 this.editor.focus();
239 } else if (code == key.space || code == key.backspace) {
239 } else if (code == key.SPACE || code == key.BACKSPACE) {
240 this.close();
240 this.close();
241 this.editor.focus();
241 this.editor.focus();
242 } else if (code == key.tab) {
242 } else if (code == key.TAB) {
243 //all the fastforwarding operation,
243 //all the fastforwarding operation,
244 //Check that shared start is not null which can append with prefixed completion
244 //Check that shared start is not null which can append with prefixed completion
245 // like %pylab , pylab have no shred start, and ff will result in py<tab><tab>
245 // like %pylab , pylab have no shred start, and ff will result in py<tab><tab>
@@ -255,11 +255,11 b' var IPython = (function (IPython) {'
255 setTimeout(function () {
255 setTimeout(function () {
256 that.carry_on_completion();
256 that.carry_on_completion();
257 }, 50);
257 }, 50);
258 } else if (code == key.upArrow || code == key.downArrow) {
258 } else if (code == key.UPARROW || code == key.DOWNARROW) {
259 // need to do that to be able to move the arrow
259 // need to do that to be able to move the arrow
260 // when on the first or last line ofo a code cell
260 // when on the first or last line ofo a code cell
261 event.stopPropagation();
261 event.stopPropagation();
262 } else if (code != key.upArrow && code != key.downArrow) {
262 } else if (code != key.UPARROW && code != key.DOWNARROW) {
263 this.close();
263 this.close();
264 this.editor.focus();
264 this.editor.focus();
265 //we give focus to the editor immediately and call sell in 50 ms
265 //we give focus to the editor immediately and call sell in 50 ms
@@ -84,27 +84,27 b' var IPython = (function (IPython) {'
84 that.save_notebook();
84 that.save_notebook();
85 event.preventDefault();
85 event.preventDefault();
86 return false;
86 return false;
87 } else if (event.which === key.esc) {
87 } else if (event.which === key.ESC) {
88 // Intercept escape at highest level to avoid closing
88 // Intercept escape at highest level to avoid closing
89 // websocket connection with firefox
89 // websocket connection with firefox
90 event.preventDefault();
90 event.preventDefault();
91 }
91 }
92 if (event.which === key.upArrow && !event.shiftKey) {
92 if (event.which === key.UPARROW && !event.shiftKey) {
93 var cell = that.get_selected_cell();
93 var cell = that.get_selected_cell();
94 if (cell.at_top()) {
94 if (cell.at_top()) {
95 event.preventDefault();
95 event.preventDefault();
96 that.select_prev();
96 that.select_prev();
97 };
97 };
98 } else if (event.which === key.downArrow && !event.shiftKey) {
98 } else if (event.which === key.DOWNARROW && !event.shiftKey) {
99 var cell = that.get_selected_cell();
99 var cell = that.get_selected_cell();
100 if (cell.at_bottom()) {
100 if (cell.at_bottom()) {
101 event.preventDefault();
101 event.preventDefault();
102 that.select_next();
102 that.select_next();
103 };
103 };
104 } else if (event.which === key.enter && event.shiftKey) {
104 } else if (event.which === key.ENTER && event.shiftKey) {
105 that.execute_selected_cell();
105 that.execute_selected_cell();
106 return false;
106 return false;
107 } else if (event.which === key.enter && event.ctrlKey) {
107 } else if (event.which === key.ENTER && event.ctrlKey) {
108 that.execute_selected_cell({terminal:true});
108 that.execute_selected_cell({terminal:true});
109 return false;
109 return false;
110 } else if (event.which === 77 && event.ctrlKey && that.control_key_active == false) {
110 } else if (event.which === 77 && event.ctrlKey && that.control_key_active == false) {
@@ -93,22 +93,28 b' IPython.utils = (function (IPython) {'
93
93
94 // some keycodes that seem to be platform/browser independant
94 // some keycodes that seem to be platform/browser independant
95 var keycodes ={
95 var keycodes ={
96 backspace: 8,
96 BACKSPACE: 8,
97 tab : 9,
97 TAB : 9,
98 enter : 13,
98 ENTER : 13,
99 shift : 16,
99 SHIFT : 16,
100 ctrl : 17,
100 CTRL : 17,
101 control : 17,
101 CONTROL : 17,
102 esc : 27,
102 ESC : 27,
103 space : 32,
103 SPACE : 32,
104 pgUp : 33,
104 PGUP : 33,
105 pgDown : 34,
105 PGDOWN : 34,
106 leftArrow: 37,
106 LEFT_ARROW: 37,
107 left : 37,
107 LEFTARROW: 37,
108 upArrow : 38,
108 LEFT : 37,
109 rightArrow:39,
109 UP_ARROW : 38,
110 right : 39,
110 UPARROW : 38,
111 downArrow: 40,
111 UP : 38,
112 RIGHT_ARROW:39,
113 RIGHTARROW:39,
114 RIGHT : 39,
115 DOWN_ARROW: 40,
116 DOWNARROW: 40,
117 DOWN : 40,
112 };
118 };
113
119
114 return {
120 return {
General Comments 0
You need to be logged in to leave comments. Login now