Making text appear manually

Hi! I’m working on adding a part to an experiment and I’m struggling.

The experiment involves a participant seeing a picture, then describing a memory associated with that picture (each picture will have about 2 minutes total). We’re trying to add a portion to the routine (code or builder) that allows us (researchers) to click a key and show “Anything else?” for five seconds at any point of the experiment (without adding time, and only for optional use if the participant stops talking during the 2 minutes).

I’ve been trying to mix and match code based on other posts but no luck (I also don’t have much experience in code, so would appreciate the help!)

Hi There,

if you have a text component in your routine (that says “Anything Else”) I would set it’s opacity to a variable $currentOpacity and set to set every frame. Then add a keyboard component that allows the key your researcher will press for the prompt to appear. Then ad a code component :code:. In the Begin Routine tab use:

currentOpacity = 0
keys_counted = 0 
startTime = 0 

in the Each Frame tab add:

if key_resp.keys:
    if len(key_resp.keys) > keys_counted: # a new has been pressed
        keys_counted += 1 # count this key 
        startTime = t # note the start time of the prompt onset 
        currentOpacity = 1
if  currentOpacity == 1 and t > startTime + 5:
    currentOpacity = 0

Hopefully that should do the trick!



Thank you so much! I tried that out, and it worked sometimes but not always (I think it only worked if I clicked m (the key I’m using) right when the prompt started but not if it’s halfway through. Just to provide additional information, we show the picture for 5 seconds then a plus sign in the center of screen for 116 seconds for a total of 121 for the whole routine. I changed t to 5 for the code and have the key and text components set for 5s start time and duration 116 s. Also, if possible, I would appreciate if you could help with how to change position of the Anywhere else to be slightly under the center!