kbs
v0.0.4
Published
very simple keyboard shortcut javascript library
Downloads
11
Maintainers
Readme
Keyboard Shortcut (simple javascript library)!
Simple javascript library to enable keyboard shortcut on the browser
npm i kbs
add script (soon to publish on npm)
<script src="https://cdn.jsdelivr.net/gh/immi5556/[email protected]/Immanuel.a7.npm/Immanuel.a7.kbs/kbs/dist/a7kbs.js"></script>
Documentation
- Focus
<div contenteditable="true" id="k1"> Content editable Shorcut ('alt' + '1')</div>
<div contenteditable="true" id="k2">Conten editable Shorcut ('alt' + '2')</div>
<div id="k3">This is not focusable, so you will see a warning in console that can not be attachable</div>
kbs.attachFocus(['alt', '1'], document.getElementById("k1")); //shortcut alt + 1
kbs.attachFocus(['alt', '2'], document.getElementById("k2")); //shortcut alt + 2
kbs.attachFocus(['alt', '3'], document.getElementById("k3")); //shortcut alt + 3
- Attach Event
html:
<button id="b2">Click Me ('alt' + 'c') </button>
js:
function click2(e) {
console.log(e);
console.log(e.kcom);
alert('Lord Jesus my Protector ');;
}
var b2 = document.getElementById("b2");
b2.onclick = click2;
kbs.attachEvent(['alt', 'b'], b2, 'click');
- Document focus out is alerted on the screen
Tested & Will work only on modern browsers