0.9.3 • Published 6 years ago

htmlelement-shortcut v0.9.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

htmlelement-Shortcut

build version package dependencies minified linter tests license hits

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>