Key

A tiny little keycode assertion library

Output will appear here…
Ctrl/⌘ & to see more. Esc to clear. Ctrl/⌘ & to see less. Esc to clear.

Example

Here's how key can work together with a DOM query library like jQuery to navigate through a [pseudo] image gallery.

var gallery = new GalleryOfAwesome();

$(window).on('keyup', function(event) {
    if (key.is(key.code.arrow.left, event.which)) {
        gallery.navigateLeft();
    } else if (key.is(key.code.arrow.right, event.which)) {
        gallery.navigateRight();
    } else if (key.is(key.code.special.esc, event.which)) {
        gallery.close();
    }
});

Usage

var key = window.key; // In browser
var key = require('key'); // Or package manager

Installation

Issues

To report a bug, submit an issue on our github repository. If you're feeling extra generous, please submit a patch via a pull request.