Permalink
Browse files

Merged all changes made in tryhaskell's version of jquery-console.

 o Tab is now a control character
 o now ignoring alt+tab
  • Loading branch information...
1 parent 6fa359b commit 1b5af6db0152efa9d20671abf5bd4bde66f0cde5 @spratt spratt committed Jun 3, 2010
Showing with 10 additions and 1 deletion.
  1. +10 −1 jquery.console.js
View
@@ -46,7 +46,7 @@
// Constants
// Some are enums, data types, others just for optimisation
var keyCodes = { left:37,right:39,up:38,down:40,back:8,del:46,
- end:35,start:36,ret:13 };
+ end:35,start:36,ret:13,tab:18};
var cursor = '<span class="jquery-console-cursor">&nbsp;</span>';
// Opera only works with this character, not <wbr> or &shy;,
// but IE6 displays this character, which is bad, so just use
@@ -100,6 +100,7 @@
},100);
}
extern.inner = inner;
+ extern.typer = typer;
extern.scrollToBottom = scrollToBottom;
})();
@@ -201,6 +202,9 @@
// Handle key press
typer.keypress(function(e){
var keyCode = e.keyCode || e.which;
+ if (isIgnorableKey(e)) {
+ return false;
+ }
if (acceptInput && cancelKeyPress != keyCode && keyCode >= 32){
if (cancelKeyPress) return false;
if (typeof config.charInsertTrigger == 'undefined' ||
@@ -223,6 +227,11 @@
);
};
+ function isIgnorableKey(e) {
+ // for now just filter alt+tab that we receive on some platforms when
+ // user switches windows (goes away from the browser)
+ return ((e.keyCode == keyCodes.tab || e.keyCode == 192) && e.altKey);
+ };
////////////////////////////////////////////////////////////////////////
// Handle console control keys
// E.g. up, down, left, right, backspc, return, etc.

0 comments on commit 1b5af6d

Please sign in to comment.