Multiple Keystroke Detection to Add Shortcuts to Your App | CtrlTab.js

shortcuts-ctrltab-js

CtrlTab.js is a library for associating hotkeys with multiple keystroke detection. CtrlTab js is a JavaScript library that is binding for modern keys to listen to keyboard events and trigger any actions when the keys are pressed.

shortcut key to run a program, open program with keyboard shortcut, how to add keyboard shortcuts, create shortcut keyboard shortcut, how to create keyboard shortcuts

How to make use of it:

1. Install and import the CtrlTab.js an ES module.

# Yarn
$ yarn add @dwtechs/ctrltab

# NPM
$ npm i @dwtechs/ctrltab
import { Keyboard } from "@dwtechs/ctrltab";

2. Or embody the ctrltab.iife.min.js within the doc.

<script src="./dist/ctrltab.iife.min.js"></script>

3. Initialize the library.

// ES
let keyboard = new Keyboard();

// Browser
var keyboard = new CtrlTab.Keyboard();

4. Bind shortcuts to a motion utilizing the addCmd technique.

// addCmd(name, ctrlKeys, keys, callback, options)
keyboard.addCmd(
  "actionName", 
  null, 
  [65], // Key A
  myAction, {
    // options here
});

5. Enable/disable modifier keys.

// addCmd(name, ctrlKeys, keys, callback, options)
keyboard.addCmd(
  "actionName", 
  { 
    ctrl: true,
    alt: false,
    shift: false,
  }, 
  [65], // Key Code or Key Name
  myAction, {
    // options here
});

6. Available choices.

{
  preventDefault: false,
  groupName: "default",
  scope: this,
  repeat: false
}

7. Set one other key for the action.

keyboard.setInputs(
  "groupName",
  "myAction",
  { 
    ctrl: false, 
    alt: false, 
    shift: false 
  },
  ["Z"]
);

8. More API strategies.

// start watching for commands
keyboard.listen(groupName);

// ignore action groups
keyboard.ignore(groupName);

// reset
keyboard.default(groupName, commandName);

// get command
keyboard.getCmd(groupName, commandName);

Assign Shortcuts To Any Actions, CtrlTab.js Plugin/Github, change keyboard shortcuts


See Demo And Download

Official Website(DWTechs): Click Here

This superior jQuery/javascript plugin is developed by DWTechs. For extra Advanced Usages, please go to the official website.