1.0.1 • Published 12 months ago

@brendangooch/keyboard-input v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

keyboard-input

a class that listens for and processes keydown events on the document body before dispatching its own custom events for the client to listen for

simply drop the class into your project, turn it on, and tell it which custom events to dispatch

const input = new KeyboardInput();
input.enable([
    'a-key-pressed',
    'ctrl-a-pressed',
    'ctrl-k-pressed',
    'left-key-pressed',
    'right-key-pressed',
    'shift-left-pressed',
    'shift-right-pressed',
    'spacebar-pressed',
    'enter-pressed'
]);
input.turnOn();
document.addEventListener('ctrl-a-pressed', () => console.log('you pressed Ctrl A'));
document.addEventListener('spacebar-pressed', () => console.log('you pressed the spacebar'));
// ...
1.0.1

12 months ago

1.0.0

12 months ago