1.1.0 • Published 2 years ago

keyes v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

keyes

A tiny package for intercepting keypresses and firing callbacks.

Install

$ yarn add keyes

Usage

keyes takes one or more Keys, consisting of a Key Value and an optional map of keyboard modifiers.

import keyes from 'keyes';
import fireToast from './fireToast';

window.addEventListener(
  'keydown',
  keyes(
    [
      {
        value: 'c',
        modifiers: { metaKey: true },
      },
      {
        value: 'c',
        modifiers: { ctrlKey: true },
      },
    ],
    fireToast,
  ),
);

API

Modifiers

The following modifier keys are available.