Timeout

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by Jeremy Jeremy 1 week, 1 day ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5734
    Avatar
    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 1 week, 2 days ago by Avatar carlap.
    #5737
    Jeremy
    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.