I’m currently programming a task in which participants move asterisks on screen by holding down certain buttons. However, I’ve run into some issues with checking whether a key remains pressed every frame using the method described here: How to detect whether if a key is being pressed down?
I’ve pared it down to the simplest level in Builder - a routine that contains only a code component and a keyboard component that has no allowed keys and waits forever for a response. The code component contains the following in “begin routine”:
kbLeft = keyboard.Keyboard(0)
…and the following in “each frame”:
currentKeys = kbLeft.getKeys('f', waitRelease=False, clear=False)
if not len(currentKeys)==0:
if currentKeys[0] == 'f':
print ("holding f")
As I understand it, setting waitRelease and clear to false should mean that getKeys returns any key that is pressed down, every frame, for as long as the key is pressed down. This should mean that the code prints “holding f” once per frame while I’m holding the key down. But this doesn’t happen - the message is displayed only once, on press, not repeated unless I release and press again.
I tried reinstalling Psychopy, but no dice. Am I making some dumb mistake that I’m not seeing?
Appreciate any help!
edit: unclear error description