| Reference | Downloads | Github

Another End Loop & Routine Question


I have the attached design for a memory study. Participants see a number of words, complete a math distractor task, and are asked to list all of the items that come to their mind one after another in each of the pages. While they have 10 opportunities to recall, I would like the loop to stop and go to the next math distractor task if the participants press space bar as the first thing to indicate that they’ve exhausted their memory.

In the code component (specifically in Each Frame) of the Recall Routine, I have the following lines. However, I think the bolded section has to be different to achieve what I want (i.e., ending One_List_Recalls loop and continue with the Math Question).

> n = len(theseKeys)
> i = 0
> while i < n:
>     if theseKeys[i] == 'return':
>         continueRoutine = False
>         break
>     if theseKeys[0] == 'space':
>         continueRoutine = False
>         One_List_Recalls.finished = True

    elif theseKeys[i] == 'space':
        inputText += ' '             
        i = i + 1

    elif theseKeys[i] == 'backspace':
        inputText = inputText[:-1]  # lose the final character
        i = i + 1

    elif theseKeys[i] in ['lshift', 'rshift']:
        shift_flag = True
        i = i + 1
        if len(theseKeys[i]) == 1:
            # we only have 1 char so should be a normal key, 
            # otherwise it might be 'ctrl' or similar so ignore it
            if shift_flag:
                inputText += chr( ord(theseKeys[i]) - ord(' '))
                shift_flag = False
                inputText += theseKeys[i]

        i = i + 1

Thank you in advance for your help.