Hotkey Plugin

Posted 2006-08-22…

Recently I needed to add hotkeys to our application for quick navigation. The result of this work is the Hotkey plugin, which I’m releasing today.

The Hotkey plugin consists of a Javascript file and three helpers that use it. You can add a hotkey using Javascript directly using the Hotkey.add() function in your application.js, or you can use the helpers in your templates. Here’s a few examples of helper usage:

Here we’ve defined three hotkeys; d, h, and p. Pressing a modifier key (which modifier key depends on the browser/platform you’re using) and the letter activates the associated function.

The plugin is very easy to use, and suits our needs. Hopefully it will help out a few others.

Update 2008-03-09: You can get the Hotkey plugin at http://github.com/bruce/hotkey; feel free to fork it and send me pull requests :-)

Take a look at the README after installation for additional setup information.