Dear,
My experiment requires a participant to enter numbers he/she has seen. The numbers on the front side of the keyboard are working, but the numbers on the right side of the keyboard are not working with this experiment although the Num lock is on. Generally, numbers on the right side of the keyboard are working except with this experiment.
Could anyone help me with this?
Best,
Sami
The keys on the numerical keys registers as “num_1”, “num_2”, etc. whereas the number-keys above the letters register as “1”, “2”, etc. So to treat both equal, do something like this:
from psychopy import event
allowed_keys = ['1', '2', '3', 'num_1', 'num_2', 'num_3']
key = event.waitKeys(keyList=allowed_keys)[0] # wait for keys and pick the first one
number = key[-1] # take the last character in the string. '2' and 'num_2' will both become just '2'.
You could also do something more general if you just want to react to all number keys:
key = event.waitKeys()[0] # allow all keys, pick first
try:
number = int(key[-1]) # convert last character to integer. ValueError if not
print number
except ValueError:
print 'you did not press a number!'
3 Likes
Hi,
This solution it is not working for me, besides the keyNameFinder from the demos of PsychoPy showing me the numpad keys as this (‘num_1’, ‘num_2’, ‘num_3’).
Should I try anything else?!
Thanks a lot!
PS: I am modifying an existing experiment. It works just fine with the regular number keys.
1 Like
Hi all,
I’m encountering the same issue with button presses from an (fMRI) button box (by Current Design). The button presses are registered just fine in a text editor window, but PsychoPy fails to recognize them. Any ideas?