JavaScript Library For Custom Keyboard Shortcuts – hot-key-lib

Category: Javascript | March 11, 2020
Author: Web-Engine
Views Total: 95 views
Official Page: Go to website
Last Update: March 11, 2020
License: MIT

Preview:

JavaScript Library For Custom Keyboard Shortcuts – hot-key-lib

Description:

hot-key-lib is a pure JavaScript library which allows you to bind any custom keyboard shortcuts for your web applications.

How to use it:

Include the JavaScript file hot-key-lib.js on the webpage.

<script src="hot-key-lib.js"></script>

Initialize the HotKey and we’re ready to go.

var hotKey = new HotKey();

Add a custom keyboard shortcut as this:

hotKey.add("CTRL+A", function (e) {
  // ...
});

Prevent default behavior from the browser.

hotKey.setup({
  "preventDefault": true
});

Start the HotKey. That’s it.

hotKey.start();

Determine whether to change the key NUMPAD-0~9 to 0~9. Default: false.

hotKey.setup({
  "noNumpadNum": true
});

Determine whether to change the key META to CTRL. Default: false.

hotKey.setup({
  "metaToCtrl": true
});

Stop listening for key events.

hotKey.stop();

Changelog:

03/11/2020

  • Add noNumPad settings.

You Might Be Interested In:


Leave a Reply