| Reference | Downloads | Github

Recording home key release and key press duration

Hi everyone!
Our group of Psychology Master students (using PsychoPy 1.85.2) is currently working on an experiment in which a response consisting of three keypresses in succession (V, B, and N) is supposed to trigger an effect of three squares filling up with color consequtively (i.e. when the next square gets filled with color, the one before becomes blank again).

In order for the effects to emulate the response as much as possible

  1. the interval between the three squares filling up should be equal to the time interval between the keypresses - this part I could still solve
  2. how long each square is color-filled should be equal to the time the respective key was being pressed down.
  3. Additionally, between trials the participants are supposed to rest their fingers on a home key (the spacebar) which must then be released to execute the three responses.

It’s part 2) and 3) we’re struggling with, since we need to

  1. record the duration how long first the spacebar and then each of our three response keys are held down.
  2. record when first the spacebar and then each of our three response keys are released

So far, I have found solutions for similar problems using either the pyglet KeyStateHandler or the ioHub keyboard component - but nothing which involves both key press duration and key release triggering. I’ve understood it in a way that I need to create KEYBOARD_CHAR events for the spacebar and the response keys, i.e. an event which triggers when a key is pressed and then the same key is released.

Having only done my first Python/Psychopy course about half a year ago (currently taking a second one), this being the first “real world” experiment I have to create, and being effectively the only person in the students’ group with any practical Psychopy knowledge, this feels like quite a tough start, so please bear with me :slight_smile: .