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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -