Millisecond Forums

Count number of key presses during video presentation?

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

By inq778 - 7/20/2015

I would like to play a video and count the number of times that a participant presses a key (e.g., spacebar) during the video presentation. During the video they will be searching for objects, and each time they see it they will press the key. I have loaded the video into the inquisit script, but I cannot figure out how to record the data such that I have this count. Any advice on code for this?
I've read through the tutorials, but this is my first time conducting a study with inquisit so there are many things I am still learning.
Thanks in advance for any help!
By Dave - 7/20/2015

You have essentially two options to do that. See https://www.millisecond.com/forums/FindPost16437.aspx
By Dave - 7/20/2015

Here's a simple, self-contained example for the 2nd (more complicated) option using /isvalidresponse:

<values>
/ spacebarpresscount = 0
/ latencies = ""
</values>

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

<trial mytrial>
/ ontrialbegin = [values.spacebarpresscount=0; values.latencies=""; ]
/ stimulusframes = [1=mytext]
/ trialduration = 5000
/ validresponse = (57)
/ isvalidresponse = [if(trial.mytrial.response==57){values.spacebarpresscount += 1; values.latencies=concat(concat(values.latencies, trial.mytrial.latency),","); false}; ]
</trial>

<text mytext>
/ items = ("Imagine a video being played...", "Imagine another video being played")
/ select = sequence
</text>

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

By inq778 - 7/20/2015

Great, thank you so much!