PennController for IBEX › Forums › Support › Issue with key press during timer
- This topic has 4 replies, 2 voices, and was last updated 4 years, 5 months ago by
carlap.
-
AuthorPosts
-
September 2, 2020 at 3:11 am #6031
carlap
ParticipantHi,
I have an experiment and it has the following elements
1. An audio of a number plays then there is a timer
2. A second audio of a number plays and there is another timer
3. Text appears and there is a timer (300 ms). The task is to determine if the text represents the product of the 2 audio numbers.
4. The text disappears and there is a newKey step to record the answer.The problem is if the subject tries to answer during the 300 ms timer that controls the appearance of the text, the answer is not captured and then the subject will multiple press until the answer is accepted and this causes problems with the reaction time.
A sample of the code is below. Any thoughts are greatly appreciated.
newText("num", row.Solution) .settings.css ("color","white") .settings.css("font-size", "200px") .print() , newTimer(300) .start() .wait() , getText("num") .remove() , newKey("pressOnArrow", "ArrowLeft", "ArrowRight") .log() .callback( getTimer ("timeout").stop() ).log("all") , newTimer("timeout", 5000).start().log().wait() , getKey ("pressOnArrow") .disable() ) .log( "Correct_answer" , row.Correct_answer ) .log( "ID" , getVar("ID")
September 2, 2020 at 10:29 am #6033Jeremy
KeymasterHi,
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.
Jeremy
September 2, 2020 at 12:28 pm #6036carlap
ParticipantHi. Thanks for the quick response. I´m sorry if it isn´t clear. What I would like is for the subject to be able to respond both during and after the 300ms, while the text is on the screen and also during the 5 seconds waiting time after it has been removed. But, I need a response during the 300ms to cancel the second waiting time. That is a response during the 300ms is captured and then the program just moves on to the next trial. A response after the 300ms sould have the same effect, captured and move on. Thanks!
September 2, 2020 at 2:35 pm #6037Jeremy
KeymasterThanks for the clarification. Then this should do what you want:
newText("num", row.Solution) .css("color","white") .css("font-size", "200px") .print() , newKey("pressOnArrow", "ArrowLeft", "ArrowRight") .log("all") .callback( getTimer("exposure").stop(), getTimer("timeout").stop() ) , newTimer("exposure", 300).start().wait() , getText("num").remove() , getKey("pressOnArrow").test.pressed() .failure( newTimer("timeout", 5000).start().log().wait() ) , getKey("pressOnArrow").disable() ) .log( "Correct_answer" , row.Correct_answer ) .log( "ID" , getVar("ID")
Let me know if problems persist
Jeremy
September 3, 2020 at 5:30 pm #6040carlap
ParticipantThat works great! You rock! Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.