Millisecond Forums

Length of Key Depression

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

By CES - 6/27/2014

Is Inquisit able to measure the length of time that a participant depresses a key?
By CES - 6/27/2014

To clarify, this would be how long they have held a key down for.
By Dave - 6/27/2014

Yes and no. Inquisit 4 (*not Inquisit 3*) is able to register key *presses* as well as key *releases*. So what you would have to do is

- register the key press in a <trial>
- store the time when the key was pressed
- register key release in a <trial>
- store the time when key was released
- derive press duration as 'time of release' minus 'time of press'

<values>
/ timeofpress = 0
/ timeofrelease = 0
</values>

<expressions>
/ pressduration = values.timeofrelease-values.timeofpress
</expressions>

<block myblock>
/ trials = [1-4=sequence(press,release,duration)]
</block>

<trial press>
/ stimulusframes = [1=presstxt]
/ ontrialend = [values.timeofpress=script.elapsedtime]
/ validresponse = (57)
</trial>

<trial release>
/ stimulusframes = [1=releasetxt]
/ ontrialend = [values.timeofrelease=script.elapsedtime]
/ validresponse = (-57)
</trial>

<trial duration>
/ stimulusframes = [1=durationtxt]
/ validresponse = (noresponse)
/ trialduration = 1000
</trial>

<text presstxt>
/ items = ("Press SPACEBAR")
</text>

<text releasetxt>
/ items = ("Release SPACEBAR")
</text>

<text durationtxt>
/ items = ("Duration: <%expressions.pressduration%>")
</text>