Typed response: punctuation

I recommend checking out this experiment for text input: https://gitlab.pavlovia.org/demos/textinput/

In the relevant section, you can add punctuation using the following:

if len(keys):
    if 'space' in keys:
        text.text = text.text + ' '
    elif 'period' in keys:
        text.text = text.text + '.'
    elif 'comma' in keys:
        text.text = text.text + ','
    elif 'apostrophe' 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]

My colleague Emily Heffernan provided this workaround to me when I was having trouble with punctuation for text input.

5 Likes