https://github.com/renddslow/keyes
https://github.com/renddslow/keyes
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/renddslow/keyes
- Owner: Renddslow
- Created: 2022-04-19T16:30:20.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-19T17:08:00.000Z (about 3 years ago)
- Last Synced: 2024-04-26T05:07:10.200Z (about 1 year ago)
- Language: TypeScript
- Size: 60.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and an
optional map of keyboard [modifiers](#modifiers).```js
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.
- [altKey](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/altKey)
- [ctrlKey](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/ctrlKey)
- [metaKey](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/metaKey)
- [shiftKey](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/shiftKey)