1.0.0 • Published 4 years ago
hotkey-chain v1.0.0
hotkey-chain
The easy way to create shortcut
Installation
npm install hotkey-chain
# or use yarn
yarn add hotkey-chain
Usage
import HotKeyChain from 'hotkey-chain'
const handler = new HotKeyChain()
.on('enter', (event, next) => {
if (someCondition) {
// do something
return
}
// Run next `enter` handler
next()
})
.on('enter', (event, next) => {
if (someCondition2) {
// do something
return
}
next()
}).handler
document.addEventListener('keydown', handler)
Or use HotKeyChainManager
quickly.
import { HotKeyChainManager } from 'hotkey-chain'
new HotKeyChainManager(document)
.on('enter', (event, next) => {
if (someCondition) {
// do something
return
}
next()
})
.on('enter', (event, next) => {
if (someCondition2) {
// do something
return
}
next()
})
.start()
Contributing
- Fork it!
- Create your new branch:
git checkout -b feature-new
orgit checkout -b fix-which-bug
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
git commit -am 'feat: some description (close #123)'
orgit commit -am 'fix: some description (fix #123)'
- Push to the branch:
git push
- Submit a pull request :)
Authors
This library is written and maintained by imcuttle, moyuyc95@gmail.com.
License
MIT - imcuttle 🐟
1.0.0
4 years ago