Create Custom Keyboard Shortcuts With The easyShortcut.js Library

Category: Javascript | November 12, 2021
AuthorwwwAlireza
Last UpdateNovember 12, 2021
LicenseMIT
Views124 views
Create Custom Keyboard Shortcuts With The easyShortcut.js Library

Just another keyboard shortcut JavaScript library for creating “hotkeys” or “cheat codes” on the page.

How to use it:

1. Import the easyShortcut.min.js library into the document.

<script src="easyShortcut.min.js"></script>

2. Trigger a function when you press A on the page.

new shortcut({
    key: "c",
    fn: () => {
      // do something
    }
})

3. Enable/disable modifier keys. Default: false.

new shortcut({
    ctrl: true,
    alt: true,
    shift: false,
    meta: false,
    key: "c",
    fn: () => {
      // CTRL+ALT+A
    }
})

You Might Be Interested In:


Leave a Reply