Ignore invalid key codes for isChar

This commit is contained in:
Kevin Ross 2015-12-13 19:28:39 -06:00
parent fdb8cf9c89
commit 6ec039b5df

View File

@ -14,7 +14,16 @@
if (typeof evt.which == "undefined") {
return true;
} else if (typeof evt.which == "number" && evt.which > 0) {
return !evt.ctrlKey && !evt.metaKey && !evt.altKey && evt.which != 8 && evt.which != 9;
return !evt.ctrlKey
&& !evt.metaKey
&& !evt.altKey
&& evt.which != 8 // backspace
&& evt.which != 9 // tab
&& evt.which != 13 // enter
&& evt.which != 16 // shift
&& evt.which != 17 // ctrl
&& evt.which != 20 // caps lock
&& evt.which != 27; // escape
}
return false;
}