yet another keyboard compatibility layer
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
jquery.keylisten.js
jquery.keylisten.min.js

README.md

jquery-keylisten

A simple keyboard compatibility layer for jquery. Inspired by jquery.hotkeys

Features

  • easy-to-remember key names instead of key codes
  • fire a single event so you can use switch for dispatching
  • handles key repeats consistently across browsers
  • listening on the document ignores key events from text accepting inputs

Usage

$(document).keylisten(function(e) {
  var dir = null;
  switch(e.keyName) {
  case "shift+up":
    dir = dir || 'top';
  case "up":
    dir = dir || 'prev';
  case "shift+down":
    dir = dir || 'bottom';
  case "down":
    dir = dir || 'next';
    move(dir, e);
    return false;
  case "enter":
  case "return":
  case "tab":
    select(e);
    return false;
  case "esc":
  case "del":
  case "backspace":
    close();
    return false;
  default:
    refresh();
    break;
  }
})

See the code for all the keynames.

License

MIT License