psychopy.org | Reference | Downloads | Github

Pressing key duration

Hi. I would like to code a little program which would measure the duration of a key which is pressed. I have the whole program and the only thing I need is a module when people see a fixation point and when they press a spacebar then this fixation point will disappear and after they release a key I will get a duration. Is it possible in psychopy or I have to use another library?

The current version of PsychoPy now provides a new keyboard hardware class that can be used in place of the older event functions:

https://www.psychopy.org/api/hardware/keyboard.html

Note that these functions provide a waitRelease parameter that allows you to measure the duration of a keypress as well as its initial onset time. The timing ability is also drastically improved.

See here for an example: