key-mapping
v1.2.1
Published
store key mappings
Downloads
4
Readme
key-mapping
store key mappings
Usage
import { createKeyMappingNode } from 'key-mapping';
const root = createKeyMappingNode({ key: '' });
root.add({ key: 'A' }).add({
key: 'B',
action() {
console.log('Hello!');
}
});
root.get('A')?.get('B')?.mapping?.action?.(); // => Hello!
or
import {
createKeyMappingNode,
addKeyMappings,
getKeyMappingNode
} from 'key-mapping';
const root = createKeyMappingNode({ key: '' });
const keyMappings = [
{ key: 'A' },
{
key: 'B',
action() {
console.log('Hello!');
}
}
];
addKeyMappings(keyMappings, root);
getKeyMappingNode(['A', 'B'], root)?.mapping?.action?.(); // => Hello!
License
The MIT license