keyshortcut

0.0.6 • Public • Published

A Shortcut Library For Web App

1. Load the Script

<script src="path/to/shortcut.js"></script>

2. Register Your Shortcuts

Define the key shortcut join with +, such as 'shift+a', 'a+b', etc.

KeyShortcut.register('g',function( key ){
    console.log("I just triggered key: " + key );
},document.querySelector('#input'));

OR

KeyShortcut.register({
    'g+k':function( key ){
        console.log("I just triggered key: " + key );
    },
    'g+a':function( key ){
        console.log("I just triggered key: " + key );
    },
    'meta+c':function( key ){
        console.log("I just triggered key: " + key );
    },
    'a+b+c':function( key ){
        console.log("I just triggered key: " + key );
    },
    'c':function( key ){
        console.log("I just triggered key: " + key );
    }
});

Readme

Keywords

none

Package Sidebar

Install

npm i keyshortcut

Weekly Downloads

1

Version

0.0.6

License

MIT

Last publish

Collaborators

  • oslh