Global Keyboard Shortcut Event Handler | Shortcut.js

Shortcut.js is a JavaScript ES6 component that provides a global keyboard event handler. This way one can announce and interact with any combination of keys. It also provides several useful methods for handling registered keyboard events.

With ~ 5Ko Mini, Shortcut.js is designed to be stable and stay as light as possible. It should be used widely so that all of your components can interact with keyboard events.

How to make use of it:

1. Download and import the Shortcut.js as an ES module.

import Shortcut from './src/Shortcut.js';

2. Initialize the Shortcut.js and we’re able to go.

const myShortCuts = new Shortcut({
      // options here
});

3. Register shortcuts as follows:

myShortCuts.register('B', () => {
  // triggered when you press B
});

myShortCuts.register('Ctrl+F', () => {
  // triggered when you press Ctrl+F
});

4. Unregister shortcuts utilizing the remove technique.

myShortCuts.remove('B');
myShortCuts.remove('Ctrl+F');
myShortCuts.removeAll();

5. Determine the important thing event to react from. Default: ‘keydown’.

const myShortCuts = new Shortcut({
      keyEvent: 'keyup'
});

6. Determine whether or not to auto-repeat the event if the secret’s held on.

const myShortCuts = new Shortcut({
      autoRepeat: false
});

7. You may also pause & resume the shortcuts utilizing the next methods:

myShortCuts.pause('B');
myShortCuts.resume('B');
myShortCuts.pauseAll();
myShortCuts.resumeAll();

Create Custom Key Binding Events, Shortcut JS Plugin/Github


See Demo And Download

Official Website(ArthurBeaulieu): Click Here

This superior jQuery/javascript plugin is developed by ArthurBeaulieu. For extra advanced usage, please go to the official website.

Related Posts

Input-Values-Using-Mouse-Drag

Create Side Sliders Input Values Using Mouse Drag | Pointer Lock

HTML Range Slider is a lightweight library to create side sliders to adjust values easily and precisely by making use of the Pointer Lock API. Side Slider…

simple-parallax-scrolling-js

Smooth and Lightweight Parallax Scroll Library in Pure Javascript

Lightweight and seamless parallax scrolling library implemented in pure javascript using hardware acceleration for additional performance. Main Features Extremely lightweight with no dependencies A few kilobytes of pure…

Convert-Form-Data-to-JSON

How to Convert Form Data to JSON with HTML Forms | FormsJS

FormsJS is a simple-to-use JavaScript library that covers type subject values to JSON in real time. The items containing the data category will be analyzed automatically. It…

editable-html-table-using-javascript

A Small jQuery Extension to Convert An Editable HTML Table

Editable Table is a small jQuery extension to convert an editable HTML table for fast data entry and validation. A small jQuery extension to convert a static…

jquery.youtube-background

Simple jQuery Plugin for Embedding YouTube Videos As Cover Background

jquery.youtube-background is a jQuery plugin built to facilitate YouTube embeds as cover wallpaper using the YouTube Embed API. There is another jQuery Youtube Video Background plugin that…

Data-Table-Generator-Tabulator

Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…