I’ve used the following in a free recall task.
if cursorCounter >= 30:
if cursorVariable=='|':
cursorVariable='.'
else:
cursorVariable='|'
cursorCounter=0
cursorCounter+=1
if subject_response_finished:
continueRoutine=False
keys = event.getKeys()
if len(keys):
if 'escape' in keys:
core.quit()
elif 'backspace' in keys:
if len(recallitems[thisitem])>0:
recallitems[thisitem] = recallitems[thisitem][:-1]
else:
recallitems[thisitem-1]=recallitems[thisitem-1]+recallitems[thisitem]
for Idx in range(thisitem,6):
recallitems[Idx] = recallitems[Idx+1]
recallitems[6]=''
thisitem=thisitem-1
elif 'delete' in keys:
recallitems[thisitem] = recallitems[thisitem][:-1]
elif 'space' in keys:
subject_response_finished=True
elif 'return' in keys and thisitem<6:
thisitem=thisitem+1
for Idx in range(6,thisitem,-1):
recallitems[Idx] = recallitems[Idx-1]
recallitems[thisitem] = ''
elif 'up' in keys and thisitem>0:
thisitem=thisitem-1
elif 'down' in keys and thisitem<6:
thisitem=thisitem+1
elif 'a' in keys:
recallitems[thisitem] = recallitems[thisitem]+'A'
elif 'b' in keys:
recallitems[thisitem] = recallitems[thisitem]+'B'
elif 'c' in keys:
recallitems[thisitem] = recallitems[thisitem]+'C'
elif 'd' in keys:
recallitems[thisitem] = recallitems[thisitem]+'D'
elif 'e' in keys:
recallitems[thisitem] = recallitems[thisitem]+'E'
elif 'f' in keys:
recallitems[thisitem] = recallitems[thisitem]+'F'
elif 'g' in keys:
recallitems[thisitem] = recallitems[thisitem]+'G'
elif 'h' in keys:
recallitems[thisitem] = recallitems[thisitem]+'H'
elif 'i' in keys:
recallitems[thisitem] = recallitems[thisitem]+'I'
elif 'j' in keys:
recallitems[thisitem] = recallitems[thisitem]+'J'
elif 'k' in keys:
recallitems[thisitem] = recallitems[thisitem]+'K'
elif 'l' in keys:
recallitems[thisitem] = recallitems[thisitem]+'L'
elif 'm' in keys:
recallitems[thisitem] = recallitems[thisitem]+'M'
elif 'n' in keys:
recallitems[thisitem] = recallitems[thisitem]+'N'
elif 'o' in keys:
recallitems[thisitem] = recallitems[thisitem]+'O'
elif 'p' in keys:
recallitems[thisitem] = recallitems[thisitem]+'P'
elif 'q' in keys:
recallitems[thisitem] = recallitems[thisitem]+'Q'
elif 'r' in keys:
recallitems[thisitem] = recallitems[thisitem]+'R'
elif 's' in keys:
recallitems[thisitem] = recallitems[thisitem]+'S'
elif 't' in keys:
recallitems[thisitem] = recallitems[thisitem]+'T'
elif 'u' in keys:
recallitems[thisitem] = recallitems[thisitem]+'U'
elif 'v' in keys:
recallitems[thisitem] = recallitems[thisitem]+'V'
elif 'w' in keys:
recallitems[thisitem] = recallitems[thisitem]+'W'
elif 'x' in keys:
recallitems[thisitem] = recallitems[thisitem]+'X'
elif 'y' in keys:
recallitems[thisitem] = recallitems[thisitem]+'Y'
elif 'z' in keys:
recallitems[thisitem] = recallitems[thisitem]+'Z'
else:
pass
newText=''
for Idx in range(7):
if numberText==1:
newText = newText+str(nWords-6+Idx)+') '
newText = newText+recallitems[Idx]
if Idx == thisitem:
newText = newText+cursorVariable
newText = newText + '\n'
newText=newText + '______________'
if newText != displayText:
displayText=newText
recall_text.setText(displayText)