14 lines
418 B
JavaScript
14 lines
418 B
JavaScript
|
|
export default function validKey(key) {
|
|
let keycode = key.keyCode || key;
|
|
|
|
let valid =
|
|
(keycode > 47 && keycode < 58) || // number keys
|
|
(keycode > 64 && keycode < 91) || // letter keys
|
|
(keycode > 95 && keycode < 112) || // numpad keys
|
|
(keycode > 185 && keycode < 193) || // ;=,-./` (in order)
|
|
(keycode > 218 && keycode < 223); // [\]' (in order)
|
|
|
|
return valid;
|
|
}
|