Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dherault/piano-keys
A JavaScript shorcuts and hotkeys librairy
https://github.com/dherault/piano-keys
Last synced: 23 days ago
JSON representation
A JavaScript shorcuts and hotkeys librairy
- Host: GitHub
- URL: https://github.com/dherault/piano-keys
- Owner: dherault
- License: mit
- Created: 2019-03-02T10:15:17.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-15T00:07:05.000Z (over 1 year ago)
- Last Synced: 2024-09-14T09:58:09.902Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://dherault.github.io/piano-keys/
- Size: 1.21 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Piano keys
[![npm version](https://badge.fury.io/js/piano-keys.svg)](https://badge.fury.io/js/piano-keys)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing)A JavaScript hotkeys librairy in less than 3KB.
Checkout the [demo](https://dherault.github.io/piano-keys/)!
## Installation
```
npm install piano-keys --save
```## Usage
```js
import hotkeys from 'piano-keys'const element = document.getElementById('hello')
hotkeys(element, 'ctrl+b', () => console.log('bold'))
hotkeys(element, 'cmd+k a', () => console.log('super settings'))
hotkeys(element, 'up up down down left right left right b a', () => console.log('konami code'))
hotkeys(element, '1', () => console.log('fire on keyup'), true)// To unregister the listeners use the return function
const unregisterHotkeys = hotkeys(element, 'a', () => console.log('pressed a'))unregisterHotkeys()
```Available descriptors:
`ctrl shift alt altgr cmd enter tab space backspace escape capslock up down left right plus contextmenu delete insert pause home end numlock`## Usage with react
Checkout [react-piano-keys](https://www.npmjs.com/package/react-piano-keys)
## Contributing
Yes, thank you.
## License
MIT