Fetching contributors…
Cannot retrieve contributors at this time
57 lines (40 sloc) 1.42 KB


Key is a tiny little keycode library for your browser. It makes keybound event assertions super simple.

Build Status


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 (, event.which)) {
    } else if (, event.which)) {
    } else if (, event.which)) {

You can even assert against a collection of keys, not just a specific key.

var input = $('input[type="text"]');

input.on('keydown', function (event) {
    if (, event.which)) {
        window.alert('No punctuation allowed!');


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


  • npm install key
  • <script src="path/to/key/key.min.js"></script>

###License The content of this library is released under the MIT License by Andrew Lawson.
You can find a copy of this license at