How to make stimulus disappear once a participant responds?

Hi folks,

I’m meeting an obstacle while building my first Psychopy experiment,

OS : Win10
**Standard Standalone? ** yes
What are you trying to achieve?: My experiment trial has a 500ms fixation, followed by a stimulus that can last at most 1500ms. During the stimulus onset, participants should respond by clicking the keyboard buttons. And the stimulus should disappear once the participant responds, and leave the screen blank to make up for a whole 2000ms. So that each trial is a total of 2000ms. However easy this may sound, I am having trouble making the stimulus disappear once a response is made and leaving the screen blank for the time remaining. Could anyone help me with this, please?

What did you try to make it work?: I tried using “Force end routine”, but it did not work. Because that would end the whole trial and start the next trial straight after. I also tried adding the code component (the following) in “each frame” and “end routine”, but that did not work either.

if key_resp.keys:
    stimulus.status = STOPPED
    key_resp.status = STOPPED

Depending on the stimulus, you may be able to hide it by just setting .opacity to 0. Failing that, you could try .setAutoDraw(False)

For text components I use text_2.text=’ ’ to empty it (note the space between the quotes since an entirely empty text box can cause other issues).

Thank you! But how do I make this happen (to set .opacity = 0) as soon as a participant responds? This is what troubles me the most honestly…

Have you tried

if key_resp.keys:


if key_resp.keys:
1 Like

Thank you so much!
I put

if key_resp.keys:
    stimulus.opacity = 0

in a code component under each frame and stimulus.opacity = 1 under end routine, and now it worked!
Thank you so much!