Millisecond Forums

Multiple responses in a single trial using different response keys

https://forums.millisecond.com/Topic24486.aspx

By jobennett - 3/28/2018

Hi,

I am trying to run a hazard perception study whereby participants are required to watch a video, and during the course of that video respond with an "a" key for when they first notice the hazard, and "l" when they need to respond to that hazard. I need to gather the data on the response time for each button press, and which key they pressed. I have seen the forum post/script about using premature responses in order to collect data on multiple responses in a single trial, but this does not seem to give information about which key they pressed when. I was wondering if it was possible to collect this data, and how it would be possible to do so?

Thank you so much in advance!
By Dave - 3/29/2018

jobennett - Wednesday, March 28, 2018
Hi,

I am trying to run a hazard perception study whereby participants are required to watch a video, and during the course of that video respond with an "a" key for when they first notice the hazard, and "l" when they need to respond to that hazard. I need to gather the data on the response time for each button press, and which key they pressed. I have seen the forum post/script about using premature responses in order to collect data on multiple responses in a single trial, but this does not seem to give information about which key they pressed when. I was wondering if it was possible to collect this data, and how it would be possible to do so?

Thank you so much in advance!

You can log the key pressed in the same way you log the latency of the response. The trial's response property returns the keyboard scan code of the key pressed (i.e. you can differentiate between "a" and "i"), and the latency property returns the latency. In a nutshell:

<block myblock>
/ trials = [1=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=mytext]
/ validresponse = (23,30)
/ isvalidresponse = [if (trial.mytrial.response == 23 || trial.mytrial.response == 30) {values.keypressed = concat(concat(values.keypressed, trial.mytrial.response), ";"); values.keypresstimes = concat(concat(values.keypresstimes, trial.mytrial.latency), ";"); false}]
/ timeout = 20000
</trial>

<values>
/ keypressed = ""
/ keypresstimes = ""
</values>

<text mytext>
/ items = ("Press A when you first notice a hazard, press I when you want to respond to the hazard.")
</text>

<data>
/ columns = [date time subject group blocknum blockcode trialnum trialcode stimulusitem response latency
    values.keypressed values.keypresstimes]
/ separatefiles = true
</data>