psychopy.org | Reference | Downloads | Github

Written response without first letter

Hello all
I am trying to record participants answer in a task that branches. That is, if they press ‘y’, a dummy loop runs in which they are asked to type their answer and if they press ‘n’, the next trial starts and skips the dummy loop.
Problem is that when you type ‘y’, it displays as a first letter when they want to type their answer. Also when they type ‘n’, it appears the next time they are supposed to type their response. I want to have them as an answer of the first part of the task but not to display on the screen when they type their answer.
End Routine in main loop
if (key_resp.keys == ‘y’):
doRecall = 1

else:
doRecall = 0

dummyLoop
In Begin Routine
import string
allLetters = list(string.ascii_lowercase)
textFill = ‘’

In each frame
keys = event.getKeys()
if ‘escape’ in keys:
. . .core.quit() # So you can quit
else:
… if keys:
if keys[0] == ‘space’:
textFill += ’ ’ # Adds a space instead of ‘space’
elif keys[0] == ‘backspace’:
textFill = textFill[:-1] # Deletes
elif keys[0] in allLetters:
textFill+=keys[0] # Adds character to text if in alphabet.
elif keys[0] == ‘return’: # record the answer in your data file:
thisExp.addData(‘answer’, textFill) # go on to the next trial:
continueRoutine = False
screenText.setText(textFill) # Set new text on screen

How can I fix the problem?