JavaScript Keyboard Controls: js-hotkeys

js-hotkeys is a jQuery plugin which enables you to create keyboard triggered events.

Update: The plugin is based on shortcut.js. You may want to use this for not being restricted with jQuery.

This is a very nice feature if you want to provide users more browsing flexibility. And also, it can be used in JavaScript testing environments like triggering a test function by clicking CTRL + t.

JavaScript Keyboard Control

A simple usage of the plugin is:

$.hotkeys.add('Ctrl+a',function(){/*DO YOUR DUTY*/});

A demo of this jQuery keyboard control plugin can be found here.

  1. Reply Binny V A July 28, 2008 at 1:21 PM

    This can be used without jQuery – try the base script for this plugin.

  2. Reply Umut M. July 28, 2008 at 1:55 PM


    Thanks for the info. I’ve updated the post to include shortcut.js.

  3. Reply Seb July 28, 2008 at 4:58 PM

    Ctrl+C it’s cool, but what about Cmd+C ?

  4. Reply Umut M. July 28, 2008 at 5:18 PM


    Im not sure about that (I’m not using a Mac right now) but would be great if you can test it through the demo and share the results.

  5. Reply Seb July 29, 2008 at 6:43 AM

    Actually Apple keys are not handled correctly. Hitting Cmd+C return the C key as Cmd isn’t a matching key.

    Apple ASCII values seems to change for webbrowsers, and I’m not able to found a valuable map of this (except here but it’s almost incomplete).

    Tonight I will make and host a web app which will return the ASCII key received on a keystroke. So we would be able to find each value for each command on each webbrowser.

    Never the less, i’ve been able to modify the jQuery plugin to handles the Cmd key (ASCII 224). This works fine, but composed Cmd keystrokes seems to send different ASCII value.

    Hope it helps,


  6. Reply Edwin July 30, 2008 at 11:56 AM

    This is really awasome! 🙂 Like it very much! Thnx 🙂

  7. Reply Tailor March 15, 2009 at 8:14 AM

    Does anyone know how i can use this functionality and sends a user to a link?

  8. Reply brian June 2, 2009 at 3:33 PM

    You need to trigger a function within the keydown keypress or keyup events.

Leave a reply