rikrikrik.com

— the home of Rik Lomas, a web developer and technology writer, specialising in HTML, CSS and JavaScript. More about me »

jQuery plug-ins

jQuery shortKeys plug-in

Examples

Try me! The keyboard shortcuts are:

  • n
  • m
  • Space
  • Space and v
  • v
  • t and y
  • t and u

Example uses following code:

$(document).shortkeys({
  'N':       function () { $('#try_me').append('N<br />'); },
  'M':       function () { $('#try_me').append('M<br />'); },
  'Space':   function () { $('#try_me').append('Space<br />'); },
  'Space+V': function () { $('#try_me').append('Space+V<br />'); },
  'V':       function () { $('#try_me').append('V<br />'); },
  't+y':     function () { $('#try_me').append('T+Y<br />'); },
  't+u':     function () { $('#try_me').append('T+U<br />'); }
});

Usage

$(document).shortkeys(json_obj, options);

or

$(document).keys(json_obj, options);

Options

split
String to split keystring into separate keys
default: ‘+’.
moreKeys
For adding more keys to the database.
takes: { ‘Keystring’: keyCode } e.g. { ‘Space’: 32, ‘.’: 190 } default: {}

Known bugs

  • Won’t work with Shift, Alt, Ctrl keys in Safari
  • Some clashes with browser shortcuts, especially in Opera

Download

© Rik Lomas 2006-2008 all rights reserved.

No part may be reproduced without the written permission of the copyright owner, unless otherwise stated