How to end coder component in psychopybuilder

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2023.2.3
Standard Standalone? (y/n) If not then what?:y
What are you trying to achieve?: pass to a new routine after a code component

**What did you try to make it work?
if ‘escape’ in keys:
continueRoutine = False

but no success…

What specifically went wrong when you tried that?:
the next routine don’t appear!


Your code needs to be in the Each Frame tab. You might want to consider using a key other than escape, as that is the default key to exit PsychoPy.

Best wishes Jens

What does your code component do? Are there any components that are set without a duration? You can have a routine with just a code component which ends when the code has finished.

Here is my printed screen of my code component.
Try to end the routine with continueRoutine=False but no success!!


You shouldn’t have a while statement which halts the experiment on win.flip in Builder. Think of the Each Frame code as being while contineRoutine==True with a win.flip() at the end.

If you have a text component in the routine you don’t need to draw it in code as well.


the following code a Each Frame tab

if  pressed_keys:
    if 'space' in pressed_keys:
        continueRoutine = False

would end a routine.

Best wishes Jens

1 Like

Beginner’s mistake!!
It works! Thanks a lot!