I\'m trying to set up a menu that can be navigated via the arrow keys. I have this working fin in Firefox.
Trying to get it to work in IE8 and after a bit of struggl
Because I sometimes do not want events to bubble for some keys, I use something like: Customize the codes/keys as you see fit.
/* handle special key press */
function checkCptKey(e)
{
var shouldBubble = true;
switch (e.keyCode)
{
// user pressed the Tab
case 9:
{
$(".someSelect").toggleClass("classSelectVisible");
shouldBubble = false;
break;
};
// user pressed the Enter
case 13:
{
$(".someSelect").toggleClass("classSelectVisible");
break;
};
// user pressed the ESC
case 27:
{
$(".someSelect").toggleClass("classSelectVisible");
break;
};
};
/* this propogates the jQuery event if true */
return shouldBubble;
};
/* user pressed special keys while in Selector */
$(".mySelect").keydown(function(e)
{
return checkCptKey(e);
});