If user doesn't press anything, automatic assignment for key to "left" key

Hi,

I am currently designing an experiment where the user has to press either “left” or “right” on a screen sequence which would be used in a later screen input.

Window 1:
Do you think that A or B will happen?
A: press left arrow key
B: press right arrow key

Window 2:
If (‘left’ in keyDecisionResponse.keys):
something to happen
elif(‘right’ in.keyDecisionResponse.keys):
something else to happen

However, if the user doesn’t press anything (which could happen if the user is not paying attention), I receive the error:
TypeError: argument of type ‘NoneType’ is not iterable

Experiment ended.

Therefore, I would like to automatically assign ‘left’ to ‘None’ in Window 1, something of the sort:
if (‘None’ in keyDecisionResponse.keys):
keyDecisionResponse.keys = ‘left’

It does not work. Also, I tried several things, but none of them worked.

Can you please help?
Thanks.

How about

if (‘None’ in keyDecisionResponse.keys):
     something to happen
elif (‘left’ in keyDecisionResponse.keys):
     something to happen
elif(‘right’ in.keyDecisionResponse.keys):
     something else to happen

?

Hello,

Thanks for the answer, but the above also triggered the same error:

“NoneType” is not iterable.

However, the following works:

if keyDecisionResponse.keys is None:
** keyDecisionResponse.keys = “left”**

1 Like