keycodemap
v1.4.7
Published
This is a project to map keyCodes/which properties of keyevents to localized key values.
Downloads
36
Readme
keycodemap
A small library to map keycodes to key names. Examples:
64 = 'A'
59 = 'SEMICOLON'
...
Features
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.
Currently available maps
Usage
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);