views:

217

answers:

3

Using jquery (if it helps), I'd like to create a shortcut key for the letter 'j'

so when someone clicks on the keyboard letter 'j', it redirects to a webpage.

is this possible?

A: 

Already asked on SO, read this thread:

http://stackoverflow.com/questions/593602/keyboard-shortcuts-with-jquery

I think, that this answer is what you are looking for (it uses a jQuery plugin):

http://stackoverflow.com/questions/593602/keyboard-shortcuts-with-jquery/1160131#1160131

Juraj Blahunka
+2  A: 

Based on this page here http://docs.jquery.com/Events/keypress

$().keypress(function (e)
{
   //74 == J
   //106 == j
   if (e.which == 74 || e.which == 106)
    {
         //redirect
    }
});
Unkwntech
+2  A: 

The short answer is yes, this is possible. See Jquery Events Keypress

If you want it to be a universal shortcut then simply bind

$(document).keypress(function(event) {
   if (event.which === 106) { window.location = 'your_url'; }
});

Remember to make it very clear to the users that this will happen. There's nothing more off putting to a user than to accidentally trigger a command they didn't know existed.

Sean Vieira