kbs

0.0.4 • Public • Published

Keyboard Shortcut (simple javascript library)!

Simple javascript library to enable keyboard shortcut on the browser

npm install: Generic badge

    npm i kbs

add script (soon to publish on npm)

<script src="https://cdn.jsdelivr.net/gh/immi5556/immanuel.npm@v0.0.3/Immanuel.a7.npm/Immanuel.a7.kbs/kbs/dist/a7kbs.js"></script>

Documentation

  1. 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

  1. 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');
  1. Document focus out is alerted on the screen

Tested & Will work only on modern browsers

Package Sidebar

Install

npm i kbs

Weekly Downloads

3

Version

0.0.4

License

MIT

Unpacked Size

14.1 kB

Total Files

7

Last publish

Collaborators

  • jimmanuel