How to record participant response?

Hello,

I am trying to create an experiment on the latest version of PsychoPy where participants are given a string to view for 5 seconds, and then have to recall and type the string they just saw. I would like the string to appear on the screen as they type, and then to be stored in an excel file.
Right now I am having trouble getting the response on the screen. I was following the code posted by @Michael and @dvbridges on a past topic , but it doesn’t seem to be working for me. When I run the program, it quits after the string is shown, but doesn’t report any errors. Do I need to add something else to have the response show up?
This is the code I have right now:

Before Experiment
import string
allLetters = list(string.ascii_lowercase)

Begin Routine
textFill = ‘’

Each Frame
keys = event.getKeys()

if ‘escape’ in keys:
cor.quit() #to exit experiment at any point

else:
if keys:
if keys[0] == ‘backspace’:
textFill = textFill[:-1] #to delete backspace
elif keys[0] in allLetters and not capitalize:
textFill+=keys[0]
# Dealing with shift
elif keys[0] in [‘lshift’,‘rshift’]:
capitalize = True
if len(keys)>1 and ‘lshift’ in keys or ‘rshift’ in keys: #if shift and letter together
keys = [key for key in keys if key not in [‘lshift’, ‘rshift’]]
if capitalize == True and keys[0] in allLetters:
textFill += keys[0].upper()
capitalize = False
elif keys[0] == ‘return’:
# go on to the next trial
continueRoutine = False
text_2.setText(textFill)

Hi There,

If you need a typed response - have you tried the textBox component in the recent release of psychopy?

Thanks,
Becca

I’m not exactly sure if I’m using the textBox component right, I’m new to PsychoPy. I have a Textbox in the participant response routine that I thought was set to display whatever I inputted into the code (I titled it displayText and set the text as ‘’.join($key_Resp2.keys)), but it doesn’t seem to be working.

Hi,

OK so welcome to PsychoPy!

The textBox component is easiest to test out in Builder view - is there a reason you need to use coder view?

To try it out:

  1. open builder, in the components tab go >responses>textBox
  2. ensure your textBox is “editable”
  3. Add a mouse click to end the routine
  4. Add a loop that repeats say 5 times to start

This should give you the beginnings to work with,
Hope that helps,
Becca

Hi,
I was able to figure out what was wrong by looking at this demo. I still needed to use some code while using the textBox in order to have some of the functions that I wanted for this experiment. Thank you for your help!