I am trying to create an experiment that involves participants entering free text. I have successfully utilized the code from this example: https://gitlab.pavlovia.org/demos/textinput
However one small issue remains: When participants enter a period or a comma, those words “period” “comma” are printed to screen instead of the symbols. This also happens when CTRL or ALT are pressed. Does anyone see a simple solution to avoid this from happening? I would be willing to block out the use of those keys if necessary.
Below is the code for Begin Routine:
modify = False
text.text = ''
event.clearEvents('keyboard')
… and for Each Frame:
keys = event.getKeys()
if len(keys):
if 'space' in keys:
text.text = text.text + ' '
elif 'backspace' in keys:
text.text = text.text[:-1]
elif 'lshift' in keys or 'rshift' in keys:
modify = True
elif 'return' in keys:
continueRoutine = False
else:
if modify:
text.text = text.text + keys[0].upper()
modify = False
else:
text.text = text.text + keys[0]