Space key response across two routines

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

OS (e.g. Win10): macOS Monterey
PsychoPy version (e.g. 1.84.x): v2021.2.3
**What are you trying to achieve?: I have a routine where green eyes appear (called Green_Neutral_Face) on a human avatar for 0.2 seconds and I want the participants to press the space key when they see this green eye colour. This routine is followed up by the eye colour going back to brown (called Brown_Neutral_Face). I want the participants to be able to respond by pressing the space key at any time during the Green_Neutral_Face trial or during the Brown_Neutral_Face trial. I was wondering how I could allow the participants to still respond by pressing the space key during the Brown_Neutral_Face trial as well as the Green_Neutral_Face trial?

Any help would be greatly appreciated!!

Hi Molly,

If possible - it would be really helpful if you could please share screenshots of your experiment with the routine where the behaviour is not as you expect - that will help forum users visualise the problem to offer more direct support!


Hi Becca,

Sorry, forgot about that! I have attached a screenshot showing where the problem is, it is in the Brown_Neutral_Face trial. I want to somehow extend participants being able to press the space key across the two trials (Green_Neutral_Face and Brown_Neutral_Face) so that when I look at the results in the spreadsheet afterwards, I have a column where I can see, if and when someone pressed the space key. Hope this helps!

The easiest option is to combine the components of Green_Neutral_Face and Brown_Neutral_Face into a single routine. You can either use code to switch the face image being shown or have one face with a duration equal to the start time of the other. Then you can use a single keyboard response.


Thanks for your help. The eyes only turn green in 10% of trials so I think I may need to go for code to switch the face image being shown, but I am new to this so have no idea how to go about this. Any suggestions?

It would be something like:

Begin Routine

eyeChange = False

Each Frame

if t > .2 and eyeChange == False and turnGreen == 1:
      eyeChange = True

Or, is it that the first 200 ms is sometimes green, in which case the code is probably the same, but the change is to the Brown Eye image since in most cases it starts with the Brown Eye image.

I hope you realise that I’ve invented some variable and component names which need changing to the correct names for your experiment.