1.3.26 • Published 3 years ago

td-set-shortcuts v1.3.26

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

A javascript package to set shortcuts, and callbacks.

  • Supports nested key order.
  • Supports focus mode.

installation

Install the npm package:

npm i td-set-shortcuts

And:

window.setShortcut = require('td-set-shortcuts');

Usage

// Set shortcuts
let shortcuts = {
   'ControlLeft': {
      'KeyH': () => {
         console.log("Hello World!");
      },
      '*': (e) => {
         if(e.key !== 'h') console.log("You pressed [control + other keys]!");
      },
   }
};

// Set the block in which commands should be executed (default: document).
let block = document;

// Set if the block is focused by default or not. (default: true).
let is_focused = true;

// Set if preventDefault should be executed (default: true)
let prevent_default = true;

// Run the package.
setShortcut(shortcuts, block, is_focused, prevent_default);

Note: Do not use alert in callback functions. When alert is executed, the keyup won't get fired, and the library won't work correctly.

1.2.25

3 years ago

1.2.26

3 years ago

1.3.26

3 years ago

1.2.18

3 years ago

1.2.19

3 years ago

1.2.20

3 years ago

1.2.23

3 years ago

1.2.24

3 years ago

1.2.21

3 years ago

1.1.17

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.16

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago