2.0.0 • Published 5 years ago

keybinds v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Keybinds

What

Multi-key keybindings. Creates only two event listeners ever (keyup, keydown). Easily add Emacs-like (or other) keybindings to your JavaScript applications.

Why

I've made bad versions of this ~20 times. Time to put it on NPM.

How

$ npm i -s keybinds

and

import { listen, unlisten } from "keybinds";

let unlistenA = listen([], 65, () => {
  console.log("a");
});

listen([17], 65, () => {
  console.log("ctrl+a");
  unlistenA();
});

listen([17, 18], 65, () => {
  console.log("ctrl+alt+a");
  unlisten();
});