jquery - disable keydown for div -
how disable keydown specific div? options i've tried have made none of divs accept keys anymore. keys want disable div 1 , 2.
here list each key does:
$(document).keydown( function(e) { var press= ""; if ( boolkeydepressed ) return; else boolkeydepressed = true; var e = e || window.event; var ltr = e.keycode ? e.keycode : e.charcode; // alert( "you pressed " + ltr ); if ( ltr == 13 ) { event.preventdefault(); } switch(ltr) { case 49: // "1" case 97: // "1" functionhandlersp("1") //does value 1 break; case 50: // "2" case 98: // "1" functionhandlersp("2") // value 2 } } //etc etc
to disable them div id "mydiv" added
if (screens[current].id=="mydiv"){ event.preventdefault(); }
and
$("#mydiv").unbind('keydown');
and
$("#mydiv).keydown(function(event) { return false; });
but none of these methods work. put them in function shows div on screen. these disable keydown divs.
what you're looking event.stoppropagation()
: http://api.jquery.com/event.stoppropagation/
Comments
Post a Comment