Force end of routine after x button press

Hey everyone,

Is it possible to have a routine that would last as long as someone did not click x times on key “t” ? How can I implement that ?

I thought about adding a keypress that only responds to “t”, and once one clicked for instance 3 times, and not only the first time, it would end the routine.

Ideally, I gave the number of times people need to click on this “t” button stored in my excel sheet, such as in one routine, participants have to click 3 times on the button “t” before it goes to the next routine, whereas other times, participants have to click 5 times on “t” before it goes to the next one.

Do you have any idea where is this feasible in Psychopy?

Best,

Alexane

Hello,

add a code-component to the relevant trial at the top line of the trial (see below)

In the Each-frame tab of the code-component, insert

if len(key_resp.keys) == howOften:
    continueRoutine = False

howOften is a column-name of an Excel-file. It stores the number of key-presses you expect your participants to make.

Best wishes Jens