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

1.2.0Β β€’Β PublicΒ β€’Β Published

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:

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

Readme

Keywords

none

Package Sidebar

Install

npm i key-combo-listener

Weekly Downloads

69

Version

1.2.0

License

MIT

Unpacked Size

8.21 kB

Total Files

7

Last publish

Collaborators

  • cangzhang