Timeout

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5734
    carlap
    Participant

    Hi,

    I’m trying to figure out how to have a response timeout if the subject doesn0t respond but move on immediately if the subject does respond. For example, if I use newKey (“FJ”) .wait() it waits forever. If I eliminate the .wait() and use a newTimer(5000) .start() .wait() it waits five seconds regardless of if the subject responds. What I want is if the subject responds it moves on immediately and if not, it moves on after five seconds.

    Thanks!

    • This topic was modified 3 years, 9 months ago by carlap.
    #5737
    Jeremy
    Keymaster

    Hi,

    You can use a timer which you end early if your participant presses a key:

    newKey("FJ").callback( getTimer("timeout").stop() ).log("all")
    ,
    newTimer("timeout", 5000).start().log().wait()
    ,
    getKey("FJ")
        .disable()
        .test.pressed().success( newText("Good job").print() )
        .failure( newText("Too slow").print() )

    Jeremy

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.