PennController for IBEX › Forums › Support › Issue with key press during timer › Reply To: Issue with key press during timer
I’m not sure I understand the problem. When I try your code, my first keypress after the 300ms timer has elapsed is captured, regardless of whether (and how many times) I tried pressing a key during those 300ms.
Are you saying you want your results file to report keypresses that happen during the 300ms, but still validate keypresses only after the 300ms? If so, this is one way of doing it:
newText("num", row.Solution) .css("color","white") .css("font-size", "200px") .print() , newKey("pressOnArrow", "ArrowLeft", "ArrowRight").log("all") , newTimer(300).start().wait() , getText("num").remove() , getKey("pressOnArrow").callback( getTimer("timeout").stop() ) , newTimer("timeout", 5000).start().log().wait() , getKey("pressOnArrow").disable() ) .log( "Correct_answer" , row.Correct_answer ) .log( "ID" , getVar("ID")
ie. you create the Key element before the 300ms timer, but only make it stop the timeout timer after those 300ms. You’ll be able to tell whether a key was pressed during the 300ms by comparing pressOnArrow‘s timestamps with timeout‘s timestamp in your results file.