PDA

View Full Version : Number Pad input


mattyi
06-12-2017, 08:26 AM
Hi all,

I'm hoping that someone knows how to get vizact.onkeydown to recognize a number pad input. For example, if I enter:


vizact.onkeydown('0',myFunction)

Vizard will recognize the 0 above the letters on my keyboard, but not the 0 on the number pad. What do I use to get it to recognize the characters from that source?

I ask because I've created a simple response time task using vizard which tracks the workload of subjects in a behavioral study. There is limited space in the environment where the study is being run, and a small USB number pad is a pretty good input device that takes up very little space.

Jeff
06-13-2017, 11:02 PM
Try using key codes (http://docs.worldviz.com/vizard/#Keyboard_key_codes.htm) instead of numbers to get the number pad key events:

def printKey(key):
print key

vizact.onkeydown(viz.KEY_KP_0,printKey,'KP_0')
vizact.onkeydown(viz.KEY_KP_1,printKey,'KP_1')
vizact.onkeydown(viz.KEY_KP_2,printKey,'KP_2')
vizact.onkeydown(viz.KEY_KP_3,printKey,'KP_3')