psychopy.org | Reference | Downloads | Github

Defining the Start Time Component by Pressing a Keyboard Button

Hi everybody! I’m using PsychoPy v 1.85.1 on my Mac.

I want to present two stimuli (picture stimuli). The first picture will start immediately when the routine start. And after participant give a response (using a keyboard), I want the second picture appears immediately. I know I can do this by inserting this: For example, I want the 2nd stimulus to appear after I pressed “A” button: $tes.keys==“a”. But what should I insert if I want the 2nd picture also be able to show up after I pressed the other button (not only the “A” button)? (e.g., a, b, c, d, e). I mean pressing one of those five buttons will also make the 2nd stimulus to appear.

I know I can do this by splitting the routine. I just want to know whether there is a way to start a stimulus after pressing a keyboard button. Because I have another experiment that needs this method (more complicated one) and I think it’ll be more confusing if I explain it here. So I want to know if this method can be done.

Thank you!

Try:

$len(tes.keys) > 0

i.e. proceed if there is at least one entry in the list of keys.

Thank you Michael, it works!