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
doRecall = 0
In Begin Routine
allLetters = list(string.ascii_lowercase)
textFill = ‘’
In each frame
keys = event.getKeys()
if ‘escape’ in keys:
. . .core.quit() # So you can quit
… if keys:
if keys == ‘space’:
textFill += ’ ’ # Adds a space instead of ‘space’
elif keys == ‘backspace’:
textFill = textFill[:-1] # Deletes
elif keys in allLetters:
textFill+=keys # Adds character to text if in alphabet.
elif keys == ‘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?