psychopy.org | Reference | Downloads | Github

KeyPress and KeyRelease on 1 key but for 2 issues

Hi,

I’m writing an experiment, letting subjects make response by pressing a key.

The interaction process (in 1 routine) is like this:
(1) In the beginning of a trial, stimulus opacity is set invisible.
(2) when subject presses a specified key down, the stimulus gets visible.
As long as the key is not released, the stimulus continuously be visible.
The subject needs to hold that key down for a while to discriminate the blurred stimulus.
(3) When the subject releases that key, the stimulus gets changed.
(4) Then the subject can report his/her discrimination result.

I tried to use the ‘waitRelease’ parameter in keyboard checker objects in codes.

If “waitRelease= False”, I can detect that key is pressed down at the first time, change the stimulus opacity. After that, if I use another keyboard checker with “waitRelease= True” for key releasing, that doesn’t work. Because, that’s for a complete key pressing event, from pressing to releasing, not from the status key is already pressed down.

Hope somebody can give me some clues.

Thanks!

It seems the Keyboard component can not make it.

Instead, I tried io.devices.keyboard. That object can detect key press and key release separately.
ref. https://www.psychopy.org/api/iohub/device/keyboard.html

It works. :slightly_smiling_face:

Hi su_ray,

I just discovered this thread, and have been dealing with the same issue for a while, where I want something to happen when a button is pressed, and something else when that same button is released.

Could you maybe share some code with me, to show me how you fixed this issue using the io.devices.keyboard?

Rose