| Reference | Downloads | Github

Numbers on the right side of the keyboard are not working


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?


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
    number = int(key[-1])  # convert last character to integer. ValueError if not
    print number
except ValueError:
    print 'you did not press a number!'


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.