A tiny little keycode library
Key is a tiny little keycode library for your browser. It makes keybound event assertions super simple.
Here's how key can work together with a DOM query library like [jQuery][jquery] to navigate through a [pseudo] image gallery.
var gallery = ;$windowon'keyup'if keyiskeycodearrowleft eventwhichgallerynavigateLeft;else if keyiskeycodearrowright eventwhichgallerynavigateRight;else if keyiskeycodespecialesc eventwhichgalleryclose;;
You can even assert against a collection of keys, not just a specific key.
var input = $'input[type="text"]';inputon'keydown'if keyiskeycodepunctuation eventwhicheventpreventDefault;windowalert'No punctuation allowed!';;
var key = windowkey; // In browservar key = require'key'; // Or package manager
npm install key
The content of this library is released under the MIT License by Andrew Lawson.
You can find a copy of this license at http://www.opensource.org/licenses/mit