1.10.0 • Published 2 months ago

@patomation/hotkey v1.10.0

Weekly downloads
26
License
ISC
Repository
github
Last release
2 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.10.0

2 months ago

1.9.0

7 months ago

1.8.0

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago