1.12.1 • Published 10 months ago

@patomation/hotkey v1.12.1

Weekly downloads
26
License
ISC
Repository
github
Last release
10 months ago

Hotkey

A small module that handles your hotkeys

Installation

npm install @patomation/hotkey

Usage

Supports using modifier keys in any order: alt+ctrl+shift+p for example, is the same as p+control+alt+shift:

import { hotkey } from '@patomation/hotkey'

hotkey('control+z', () => {
    //Do some undo action
});

Supports alpha numeric characters and more

hotkey('enter', () => {
    //Do something when user hits enter
});

Add hotkey functions for arrow keys by using uparrow, downarrow, leftarrow and rightarrow

hotkey('downarrow', () => {
    //Down arrow function
});

new features

To have events for key up and key down. This is now supported.

hotkey('f')
.down(() => {
  //Do something when f key is down
})
.up(() => {
  //Do something when f key is up
})

Note: Adding up and down methods supports modifiers in hotkey commands. Additionally this could be written this way:

hotkey('shift+f', () => {
  //Do something when f key is down
}).up(() => {
  //Do something when f key is up
})

Development

  1. clone repo
  2. Install dependencies npm install
  3. eslint: npm run lint
  4. build lib folder with rollup with typescript overrides npm run prebuild

View The files that will be published

npm pack && tar -xvzf *.tgz && rm -rf package *.tgz

Tests

npm test

Contributing

If you have any updates fork the repo and make a pull request.

1.12.1

10 months ago

1.12.0

10 months ago

1.11.0

10 months ago

1.10.0

1 year ago

1.9.0

2 years ago

1.8.0

4 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago