jquery - keydown not firing on div -
jquery - keydown not firing on div -
i'm having issues keydown. when page on div "screena" user has 2 options, press space or "i" key. "i" key shows alert, , space bar shows div screentimer
. when user on div screentimer
should able press right arrow key phone call starttesting()
, console log.
the key , space bar work, right arrow key (39) nothing, , doesn't display console log either.
$(document).keydown( function(e) { if ( boolkeydepressed ) return; else boolkeydepressed = true; var e = e || window.event; var ltr = e.keycode ? e.keycode : e.charcode; var trans = ""; if ( ltr == 13 ) { event.preventdefault(); } switch(ltr) { case 73: // "i" key if (!$('screena').is(':visible')) { alert("i key"); } break; case 32: // space bar if (!$('screena').is(':visible')) { showdiv('screentimer'); hidediv("screena"); } break; case 39: // right arrow key if (!$('screentimer').is(':visible')) { console.log("timer"); starttesting(); } break; } });
u have utilize keypress not keydown, seek code keypress
jquery switch-statement keydown
Comments
Post a Comment