0.9.3 • Published 7 years ago
htmlelement-shortcut v0.9.3
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 --saveor
yarn add htmlelement-shortcut --saveprerequisites
for browser
<script src="node_modules/htmlelement-shortcut/distrib/htmlelement-shortcut.min.js"></script>Availables operations
- shortcut
- unshortcutusage
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>