Here is some examples of code you might use. Add your own Case parts as needed, put your selectors in to match your structure.
One has passed the current selection, the other has not.
Use as you wish and make specific to your need.
/* handle special key press */
function checkKey(e)
{
var shouldBubble = true;
switch (e.keyCode)
{
// user pressed the Tab
case 9:
{
$(".pickMyClass").toggleClass("pickSelectVisible");
$("#someOtherClass").toggleClass('pickHighlight');
shouldBubble = false;
break;
};
// user pressed the Enter
case 13:
{
$(".pickMyClass").toggleClass("pickSelectVisible");
$('.pickEntryArea').trigger('change'); /* we made changes so trigger it */
$("#someOtherClass").toggleClass('pickHighlight');
break;
};
// user pressed the ESC
case 27:
{
$(".pickMyClass").toggleClass("pickSelectVisible");
$("#someOtherClass").toggleClass('pickHighlight');
break;
};
};
/* this propogates the jQuery event if true */
return shouldBubble;
};
/* handle special key press */
function checkFieldKey(e, me)
{
var shouldBubble = true;
switch (e.keyCode)
{
// user pressed the Enter
case 13:
{
$(me).blur();
$("#someSpecialSelect").focus();
shouldBubble = false;
break;
};
};
/* this propogates the jQuery event if true */
return shouldBubble;
};
/* user pressed special keys while in Select */
$(".someSelect").keydown(function(e)
{
return checkKey(e);
});
/* user pressed special keys while in Select */
$(".somethingOther").keydown(function(e)
{
return checkFieldKey(e, $(this));
});