| Reference | Downloads | Github

Event getKeys not working in Psychopy3 with Python 3

Hi there!

I’ve been using Psychopy3 with Python 2 no problems.

But I’ve been thinking about making the move to Python 3, and I’m having this weird issue were event.getKeys is not registering keypresses at all!

If I run:

win = visual.Window([400,400])

and hold down any key on my keyboard, response still registers as a empty list

Sorry if this seems like such a silly issue but I can’t figure out what’s going on!


I do feel silly! I wasn’t providing a key list to event.getKeys() to query. I just assumed that it would query all the keys without any arguments. The correct code would be:

win = visual.Window([400,400])

The event.getKeys() will work without the None arg added because that is the default for the keyList parameter. I think the problem may be with how you are attempting to record your keys, as it works fine when you use a code component in Builder. E.g., in the every frame tab:

key = event.getKeys()
if key: