Ban specific type of keybord entry in text feedback

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 3.07
Standard Standalone? Yes

What are you trying to achieve?:
I’m trying to lock the keybord entry for text feedback to accept only numbers. For the text entry by the participant I am using the code snippet by jacanterbury [PsychoPy-snippets/textInput at master · jacanterbury/PsychoPy-snippets · GitHub]

What did you try to make it work?:
I found psychopy.event.keys (keyList) in the online material of PsychoPy (psychopy.event - for keypresses and mouse clicks — PsychoPy v2021.2).
I don’t know how to set up the keyList and where I have to save it.

Hi @liam, you just need to add a list of allowed keys to the keyList param in event.getKeys:

keys = event.getKeys(keyList=['1','2','3','4'])

Just for info, that code in the code component is actually a modified version of the inputText demo on Pavlovia (although, jacanterbury is very similiar).

https://pavlovia.org/run/demos/textinput/html/

Hi @dvbridges, thank you very much. This is helping me a lot.