keyshortcut
v0.0.6
Published
A Simple Library to Set Key Shortcut in webpage
Downloads
11
Readme
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 );
}
});