Collect response via response button OR key press

PennController for IBEX Forums Support Collect response via response button OR key press

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5102
    janina
    Participant

    Hello,

    I’m trying to allow participants to continue on to the next trial by either pressing the space bar OR by clicking a response button. So far, I’ve only managed to have people press the space bar and then the response button. Is there a way I can offer both options simultaneously and skip the one that was not selected? I’m trying to achieve that the same experiment version can be run both on desktop computers and mobile devices.

        newText("<p>Press SPACE to continue <p>")
            .center()
       ,
        newKey(" ")
            .wait()   
       ,
        newButton("Space")
            .print()
            .center()
            .wait()

    Thank you!

    #5103
    Jeremy
    Keymaster

    Hi!

    I admit that it’s a bit tricky, but as alluded to on this page of the tutorial, the way to represent a click OR a keypress is to use a Selector, so in your case this is what you would do:

        newText("Press SPACE to continue ")
            .center()
       ,
        newButton("Space")
            .print()
            .center()
       ,
        newSelector()
            .add(getButton("Space"))
            .keys( " " )
            .wait()
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.