Keydown Event Codes
4 answers
var inInterval = function (code, min, max) {
return code >= min && code <= max;
};
if (inInterval(e.keyCode, 90, 97) || inInterval(e.keyCode, 104, 110))
Or, slightly better:
var interval = function (min, max) {
return {
min: min,
max: max,
contains : function (elem) {
return this.min <= elem && elem <= this.max;
}
};
};
interval(90, 98).contains(92); // true
interval(90, 98).contains(15); // false
+6
source to share