1.0.0 • Published 4 years ago

keyboard-master v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

KeyboardMaster

KeyboardMaster is a simple library for handling keyboard shortcuts in Javascript.

The library is very small it's just 2.4kb. (without minifying)

Getting started

  1. Include KeyboardMaster on your page before the closing </body> tag

    <script src="/path/to/KeyboardMaster.min.js"></script>

    or install KeyboardMaster from npm and require it

    var KeyboardMaster = require('KeyboardMaster');
  2. Add some keyboard events to listen for

    <script>
        document.body.addKeyboardEvents({
            keyBindings: [
                { keyBinding: 'CTRL + SHIFT + :', action: () => { alert('ctrl + shift + : works.'); } },
                { keyBinding: 'P', action: () => { alert('p pressed') } },
            ],
            passwordBindings: {
                timeout: -1,
                bindings: [
                    {
                        passwordBinding: 's-a-h-i-t-h-y-a-n', action: () => {
                            console.log('typed my name!')
                        }
                    }
                ]
            }
        });
    </script>

Why KeyboardMaster?

There are a number of other similar libraries out there so what makes this one different?

  • There are no external dependencies, No more incompatibility issues.
  • You can bind certain keyboard shortcuts to certain elements.

Developer Note

  • KeyboardMaster extends the HTMLElement object with some methods.

Documentation

Documentation not ready. Help me out.

1.0.0

4 years ago