A small library to map keycodes to key names. Examples:
64 = 'A'
59 = 'SEMICOLON'
...
You can change the keyboard layout by country string defined after ISO 3166-1 . Example for United States of America = "US". You can pass in a javascript key event or the key code as a number to get the Name.
Click to expand
United States of America ("US") Germany ("DE")Install the package using npm
with npm install --save keycodemap
.
Import it to your project
const keycodemap = require('keycodemap');
The default location is 'US'.
Now you can use map()
to get the key names:
// event is a javascript key event or a number
var name = keycodemap.map(event);
// e.g. if the key code was 59 it will print 'SEMICOLON'
console.log(name);
To change the locale, just call
// newLocationString i a ISO 3166-1 string e.g. "DE"
keycodemap.useMap(newLocationString);