key-comb-listener
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

  • typescript support

Readme

Keywords

none

Package Sidebar

Install

npm i key-comb-listener

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

8.47 kB

Total Files

7

Last publish

Collaborators

  • cangzhang