Lightweight Key Binding & Mapping Library – keylani.js

Category: Javascript | April 3, 2019
Author: akaizn-junior
Views Total: 151
Official Page: Go to website
Last Update: April 3, 2019
License: MIT

Preview:

Lightweight Key Binding & Mapping Library – keylani.js

Description:

keylani.js is a small JavaScript library to bind and map keyboard shortcuts and key presses in a simple way.

How to use it:

Download and import the keylani.js library from the dist folder.

<script src="/dist/umd/keylani.min.js"></script>

Show keyboard shortcuts on an element (OPTIONAL).

<button data-keybind="t+1" data-keyshow="true">T & 1</button>

Bind keyboard shortcuts and execute callbacks when the keys are pressed.

Keylani.bind('Control + c', (pressed) => { 
  // do something
});

Bind an object of keyboard shortcuts.

Keylani.map({
  'a': (pressed) => { // do something },
  'Ctrl + a': (pressed) => { // do something },
  ...
});

Run all keyboard bindings when you click a trigger element.

Keylani
  .when('click', document.getElementById('clickhere'))
  .run({
    // do something
  });

You Might Be Interested In:


Leave a Reply