Display DotStim until response is given OR for max 3 seconds

Hi everyone

I know a bit of PsychoPy coder, but now I have to write my own experiment from scratch and I’m stuck. I want to do a coherence random dot motion task. The stimulus (the moving dots) should be showed until a response is given, with a maximum of 3 seconds. So participants have max 3 seconds time to gather the information about in which direction the dots are moving, but they can answer before the 3 seconds have passed if they don’t need that much time to make a decision.
My problem is that I’m stuck in an infinite while loop, the dots are shown forever, even though I’m pressing the respone keys. The relevant code starts on line 103.
I just want the dots to be shown for max 3s, if participants answer before 3s, a new trial (so new dots) should be shown.

181022bis.py (6.3 KB)

Thank you for your help.

Hi @CharlotteA,

I suspect that this line is the problem:

            if keypress == '2' or keypress == '8':

As far as I am aware, getKeys() returns a list and not single characters. So it should be

            if '2' in keypress or '8' in keypress: