views:

46

answers:

2

I'm using jeegoo context menu jquery plugin which overrides the arrow keys in order to navigate the menu. I have an input field in the menu and when in the input field the left and right arrow keys don't function.

Is there a way I can add an exception so that when I'm in an input field the left and right arrow keys revert back to default behavior?

Here's the code for the keystroke override.

$(document).bind('keydown.jeegoocontext', function(e){
 switch(e.which)
 {
     case 38: //keyup
        **misc code**
         return false;
     case 39: //keyright
        **misc code**
         return false;
     case 40: //keydown
        **misc code**
        return false;
     case 37: //keyleft
        **misc code**
        return false;
     case 13: //enter
        **misc code**
        break;
     case 27: //escape
        **misc code**
         break;
     default:
         break;
 }
 }).bind('keyup.jeegoocontext', function(e){
 window.clearInterval(_global.keyUpDown);
 _global.keyUpDownStop = false;
 });

e.stopPropagation();
A: 

The developer of the plugin I'm using responded back to me with a solution to override the keystrokes controls for the input field.

$(‘myInputField’).keydown(function(e){
    {switch(e.which){
         case 39: e.stopPropagation();return true;
         case 37: e.stopPropagation();return true;}});
James
A: 

Just make sure that e.stopPropagation() isn't called for elements that you want to default behavior for.

Chris Martin