Try coding to make a slider appear only after pressing the space bar

Hi everyone,

During the experiment, we present images to the participants, I made an excel file and a loop so that psychopy selects them randomly. I would like for each image, if and only if the participants press the spacebar, they are prompted to respond on a slider about a feeling, then the loop continues to present the images. If the participants do not press the spacebar then no slider and the images continue to scroll randomly.

here it’s the code line i put in “begin routine” : = False

here it’s the one i put in “each frame” :

theseKeys = event.getKeys(keyList=[‘space’,‘none’]) = True if ‘space’ in theseKeys else False

knowing that “descriptionJVscale” is the slider i want to show after the press on the spacebar.

You could have a slider routine which ends if space isn’t pressed. The following will work if the response is space or nothing and the keyboard component is called key_resp

if key_resp.keys:
     continueRoutine = False

What do I have to do with this code line ? mines are okay ? where do i have to put your code line ? sorry, i’m a beginner with coding.

here is my experiment design, i put my code line in “block1”