htmlelement-Shortcut
The lastest version of this document is available on Github > htmlelement-shortcut
Allows you to associate a keyboard shortcut with an HTML element (input, textarea, document, etc.).
The keyboard shortcut on an element can be propagated to its parent elements or not.
Installation
npm install htmlelement-shortcut --save
or
yarn add htmlelement-shortcut --save
prerequisites
for browser
<script src="node_modules/htmlelement-shortcut/distrib/htmlelement-shortcut.min.js"></script>
Availables operations
- shortcut
- unshortcut
usage
See Demo
<input id="t1" type="text" />
<input id="t2" type="text" />
<script>
document.querySelector("#t1").shortcut("ctrl+F1", function() {
alert("ctrl+F1 on input t1");
}, false);
document.querySelector("#t2").shortcut("ctrl+F1", function() {
alert("ctrl+F1 on input t2");
}, false);
document.querySelector("#t2").shortcut("alt+G", function() {
alert("alt+G on input t2");
}, false);
</script>