Adding the "button down" effect on keydown with JQuery? -


how can add "button down" effect when button selected , key pressed? behaviour of actual press works, it's no effect ever shown.

to more specific: have set of buttons can traversed through using left , right arrow keys. , when enter pressed, selected button carry-out it's onclick behaviour.

thanks!

here fiddle example: http://jsfiddle.net/maniator/dblem/

var index = 0; var buttons = $('button'); var max = buttons.length - 1; var buttonon = buttons.eq(index).addclass('on');  $(document).keydown(function(e) {     switch (e.keycode) {     case 39:         {             index++;             if (index > max) {                 index = 0;             }             break;         }     case 37:         {             index--;             if (index < 0) {                 index = max;             }             break;         }     case 13:         {             buttonon.trigger('click');         }     }     buttonon = buttons.eq(index);     buttons.removeclass('on');     buttonon.addclass('on'); });   $('button').click(function(){     alert(this.innerhtml); }); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -