Let us have a look at the simple javascript code, that can be used to add hotkeys to our web application. I tried using jquery hotkeys plugin and two more plugins, but they didn’t work for me.
So I ended up handling the keydown event of my own.
var isAlt = false; document.onkeyup = function(e) { if (e.which == 18) //18 is the keycode for 'Alt' isAlt = false; } document.onkeydown = function(e) { if (e.which == 18) isAlt = true; else if (e.which == 69 && isAlt == true) { //69 is the keycode for 'e' function1(); // executed when alt+e is pressed return false; } else if (e.which == 71 && isAlt == true) { function2(); // executed when alt+g is pressed return false; } ... }
Hope this helped.
Cheers!
~~Amit Jain~~
amit@intelligrape.com
IntelliGrape Softwares
This entry was posted
on September 28th, 2009
at
10:55 pm and is filed under
Javascript/Ajax/JQuery .
You can follow any responses to this entry through the
RSS 2.0 feed.
You can leave a response, or trackback from your own site.
