keycodes-map
v1.0.2
Published
Simple Javascript helper object to work with keyboard keyCodes with ease
Downloads
18
Maintainers
Readme
keycodes-map
Instalation
npm install keycodes-map
Description
keycodes-map
provide u map of all keyboard keyCode values in nicely structured and named way where u can access every key with ease, plus few useful functions to check is pressed keyboard event alpahanumeric
, number
or letter
Usage
Compare with pressed event keyCode :
import { keys } from 'keycodes-map';
document.addEventListener('keyup', (event) => {
if (event.keyCode === keys.enter) {
console.log(`${event.code} is pressed`); // Enter is pressed
}
});
Check is pressed key alphanumeric :
import { isAlphanumeric } from 'keycodes-map';
document.addEventListener('keyup', (event) => {
if (isAlphanumeric(event.keyCode)) {
console.log(`Alphanumeric key is pressed`);
}
});
Check is pressed key number :
import { isNumber } from 'keycodes-map';
document.addEventListener('keyup', (event) => {
if (isNumber(event.keyCode)) {
console.log(`Number is pressed`);
}
});
Check is pressed key letter :
import { isLetter } from 'keycodes-map';
document.addEventListener('keyup', (event) => {
if (isLetter(event.keyCode)) {
console.log(`Letter is pressed`);
}
});