1.0.0 • Published 6 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-chainUsage
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-neworgit 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
6 years ago