htmlelement-shortcut

0.9.3 • Public • Published

htmlelement-Shortcut

build version package dependencies minified linter tests license hits

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>

Package Sidebar

Install

npm i htmlelement-shortcut

Weekly Downloads

0

Version

0.9.3

License

MIT

Unpacked Size

10.8 kB

Total Files

5

Last publish

Collaborators

  • sylvain59