hotkey-chain
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

hotkey-chain

Build status Test coverage NPM version NPM Downloads Prettier Conventional Commits

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 or git 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)' or git 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 🐟

Package Sidebar

Install

npm i hotkey-chain

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

12 kB

Total Files

13

Last publish

Collaborators

  • moyuyc