Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cangzhang/key-combo-listener
👂 for key combo and 🔥
https://github.com/cangzhang/key-combo-listener
keyboard listener typescript-support vanilla-javascript
Last synced: 2 months ago
JSON representation
👂 for key combo and 🔥
- Host: GitHub
- URL: https://github.com/cangzhang/key-combo-listener
- Owner: cangzhang
- Created: 2020-03-04T11:59:14.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-11T01:18:47.000Z (over 3 years ago)
- Last Synced: 2024-10-12T14:08:46.842Z (3 months ago)
- Topics: keyboard, listener, typescript-support, vanilla-javascript
- Language: JavaScript
- Homepage: https://npm.im/package/key-comb-listener
- Size: 798 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Key Combo Listener
👂 for key combo and 🔥.
With typescript support of course.
## Installation
With yarn:
```
yarn add key-combo-listener
```With npm:
```
npm install key-combo-listener --save
```## How to use
Use it like this:
```javascript
import keyComboListener from 'key-combo-listener';const keyCombo = ['ArrowUp', 'ArrowDown'];
const timeout = 5000;
const listener = keyComboListener(keyCombo, timeout, result => {
if (result.done) {
return console.log(`🔥 something!`);
}console.log(`keep 👂`, result);
})document.addEventListener(`keydown`, listener);
```## Configuration
`key-combo-listener` accepts 3 parameters.
| Param | Type | Default Value |
|----------|------------|---------------|
| key comb | string[] | [] |
| timeout | number(ms) | Infinity |
| callback | function | () => null |## TODO
- [x] ~~typescript support~~