Adding instant feedback on mouse click

Hello all,
How to create a code for adding instant feedback on mouse click?
My code is as follows: (Ps: my Mouse component is named “resp” )

The error code is as follows:

Traceback (most recent call last):
  File "D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py", line 903, in <module>
    if resp.keys == corrAns:
AttributeError: 'Mouse' object has no attribute 'keys'

I would appreciate that if someone can help me find my mistakes or show me the right code. :revolving_hearts:

.keys is for keyboard responses not mouse clicks.

You could try resp.isPressedIn(corrAns)

1 Like

Sorry to bother you, I am afraid the problem has not been solved.
The error code is:

Traceback (most recent call last):
  File "D:\psychopy\RWO_LTM\Exp1 - copy_lastrun.py", line 843, in <module>
    if resp.ispressedln:
AttributeError: 'Mouse' object has no attribute 'ispressedln'


I am confused. I would appreciate any help or suggestions.

Finally, I make it. :grinning:
Thanks anyway. :innocent:

The correct code: (in the “Begin Routine” option card)

if resp.clicked_name[0] == corrAns:
    feedback = "Correct!"
else:
    feedback = "Wrong!"

Pressed has a capital P

However, I see you’ve found the other solution.

1 Like