key-comb-listener
v1.0.0
Published
๐ for key comb and ๐ฅ
Downloads
4
Readme
Key Comb Listener
๐ for key comb and ๐ฅ.
With typescript support of course.
Installation
With yarn:
yarn add key-comb-listener
With npm:
npm install key-comb-listener --save
How to use
Use it like this:
import keyCombListener from 'key-comb-listener';
const keyComb = ['ArrowUp', 'ArrowDown'];
const timeout = 5000;
const listener = keyCombListener(keyComb, timeout, result => {
if (result.done) {
return console.log(`๐ฅ something!`);
}
console.log(`keep ๐`, result);
})
document.addEventListener(`keydown`, listener);
Configuration
key-comb-listener
accepts 3 parameters.
| Param | Type | Default Value |
|----------|------------|---------------|
| key comb | string[] | [] |
| timeout | number(ms) | Infinity |
| callback | function | () => null |
TODO
- [x] ~~typescript support~~