##// END OF EJS Templates
add is_typing utility...
MinRK -
Show More
@@ -225,8 +225,8 b' IPython.utils = (function (IPython) {'
225 "$1<a target=\"_blank\" href=\"$2$3\">$2$3</a>");
225 "$1<a target=\"_blank\" href=\"$2$3\">$2$3</a>");
226 }
226 }
227
227
228 // some keycodes that seem to be platform/browser independant
228 // some keycodes that seem to be platform/browser independent
229 var keycodes ={
229 var keycodes = {
230 BACKSPACE: 8,
230 BACKSPACE: 8,
231 TAB : 9,
231 TAB : 9,
232 ENTER : 13,
232 ENTER : 13,
@@ -253,7 +253,36 b' IPython.utils = (function (IPython) {'
253 DOWN_ARROW: 40,
253 DOWN_ARROW: 40,
254 DOWNARROW: 40,
254 DOWNARROW: 40,
255 DOWN : 40,
255 DOWN : 40,
256 COMMAND : 91,
256 LEFT_SUPER : 91,
257 RIGHT_SUPER : 92,
258 COMMAND : 93,
259 };
260
261
262 var is_typing = function (event) {
263 // return whether a key event is probably typing (used for setting the dirty flag)
264 var key = event.which;
265 if ( key < 46 ) {
266 if (
267 ( key == keycodes.BACKSPACE ) ||
268 ( key == keycodes.TAB ) ||
269 ( key == keycodes.ENTER )
270 ) {
271 return true;
272 } else {
273 return false;
274 }
275 } else {
276 if (
277 ( key == keycodes.LEFT_SUPER ) ||
278 ( key == keycodes.RIGHT_SUPER ) ||
279 ( key == keycodes.COMMAND )
280 ) {
281 return false;
282 } else {
283 return true;
284 }
285 }
257 };
286 };
258
287
259
288
@@ -283,6 +312,7 b' IPython.utils = (function (IPython) {'
283 keycodes : keycodes,
312 keycodes : keycodes,
284 fixCarriageReturn : fixCarriageReturn,
313 fixCarriageReturn : fixCarriageReturn,
285 autoLinkUrls : autoLinkUrls,
314 autoLinkUrls : autoLinkUrls,
315 is_typing : is_typing,
286 points_to_pixels : points_to_pixels,
316 points_to_pixels : points_to_pixels,
287 browser : browser
317 browser : browser
288 };
318 };
General Comments 0
You need to be logged in to leave comments. Login now