Using both mouse and keyboard

Hello
I want to use both keyboard and mouse in Psychopy.
in the first trial, participants are shown a word (e,g., bookstore) and try to remember it. then they will press the space bar and go to the next trial in which the will see the word (e,g., bookstore) that read before, while the word has been taken apart into two parts like “book” “store” . and they will be asked a question and they will answer by pressing two different keys on keyboard.
in the next screen, they will be asked about the word (e,g., bookstore), and they have to chose between YES and NO options by Mouse.
if the answer is correct, they they will go to next trial, but if the answer is incorrect, they will receive an error feedback.

Now, the question is do I need write any code? if so, could you please help me with that?
I am using this code, but I am not sure if I am using it correctly:

second, should I consider different loops? Or I can put them all in one loop?
I have considered like in screenshot:

I appreciate it your time and help.

Best,
Hamid

Unfortunately, mouse.corr doesn’t yet work.

You could try:

if Answer in mouse_2.clicked_name:
          continueRoutine = False

Hi,
Yes, That works somehow. thanks. But still there is some issue with that.

As I said before
“in the first trial, participants are shown a word (e,g., bookstore) and try to remember it. then they will press the space bar and go to the next trial in which the will see the word (e,g., bookstore) that read before, while the word has been taken apart into two parts like “book” “store” . and they will be asked a question and they will answer by pressing two different keys on keyboard.
in the next screen, they will be asked about the word (e,g., bookstore), and they have to chose between YES and NO options by Mouse .
if the answer is correct, they they will go to next trial, but if the answer is incorrect, they will receive an error feedback”.
Please see the screenshot (the excel file has 121 rows)


Now, the code that you gave is works in a way that when clicking on YES or NO option, they will receive the error feedback. But the first problem is, whatever they choose, they will receive error feedback! But I want it to show the error feedback when the chosen answer is incorrect. I would appreciate it if you could help me to figure it out.

The second issue is, after receiving error feed back, it should show another word from the first column (as shown in the screenshot of the excel file) and show the two parts word, then ask YES-NO question. But it doesnt go to the first column! And keeps showing the yes-no question until 121 character, then shows the word of the first column.
In short, it shows the one word from first column (e.g., briefcase), then shows two part words of that word (like “brief” and “case”, then all 120 yes-no words! While it has to show one word from first column, then the first two part words, then one yes-no words. if the answer is correct, then show the new word form the first column etc. But if the answer is incorrect, it has to show error feedback. Does that make sense?

Thank you so much for your time and help.
Hamid

I’m not going to look at your second issue here. I think I’ve seen it in another thread.

Regarding the mouse, try printing the value of mouse_2.clicked_name to the console using print(mouse_2.clicked_name)

The issue might be that your column says Yes but your clickable polygon is called YES

Thank you for your response. I dont know which part of psychopy is named console. I googled it, but still dont know it. sorry.
But,I changed the clickable polygon to another name which caused more issue.

The results of print statements go to the Runner locally, along with error messages.

I dont know how to thank you for your time and help, dear. And also I appreciate your quick answer.

Could you please take a look at the attached. I made a change. now it goes


through the process that I want which is showing one word from the first column, then the first two-part words, then one yes-no words.

What I did was removing one loop that I had considered for error-feedback.

Now, the only issue is whatever I chose (either YES or NO) I get the error feedback. Do you have any idea?

and the code now is like this

I dont know how to consider NO in the code as well.
Because sometime YES is the correct answer and sometime NO is the correct answer (if you see in the excel file.

clicked_name will return a string.

Rather than separate ‘YES’ and ‘NO’ (quotes required) it would be easier if you used CorrectAnswer (without quotes) and then put YES and NO in that column (without quotes)

Oh, I just use quotes here in my post to make it clear that they are tow parts of one word. Indeed, I have not use quotes in my files or in Psychopy

Hi Michael,

I am programing a study in which in the first trial, participants are shown a word (e,g., bookstore) and try to remember it. then they will press the space bar and go to the next trial in which the will see the word (e,g., bookstore) that read before, while the word has been taken apart into two parts like “book” “store” . and they will be asked a question and they will answer by pressing two different keys on keyboard.

in the next screen, they will be asked about the word (e,g., bookstore), and they have to chose between YES and NO options by Mouse .
if the answer is correct, they they will go to next trial, but if the answer is incorrect, they will receive an error feedback”.

Please see the screenshot (the excel file has 121 rows)

Now, I got a code (form a kind person named wakecarter) that works in a way that when clicking on YES or NO option, they will receive the error feedback. But the first problem is, whatever they choose, they will receive error feedback!

But I want it to show the error feedback when the chosen answer is incorrect. I would appreciate it if you could help me to figure it out.

The second issue is, after receiving error feed back, it should show another word from the first column (as shown in the screenshot of the excel file) and show the two parts word, then ask YES-NO question. But it doesnt go to the first column! And keeps showing the yes-no question until 120 character, then shows the word of the first column.

In short, it shows one word from the first column, then shows two-part words, then yes-no words option to choose. if the answer is correct, then it will show the new word from the first column etc. But if the answer is incorrect, it has to show error feedback. Does that make sense?

Now, the only issue is whatever I chose (either YES or NO) I get the error feedback. Do you have any idea?

I dont know how to consider NO in the code as well.

Because sometime YES is the correct answer and sometime NO is the correct answer (if you see in the excel file)

Here is the code that I am using:

Best,
Hamid

The code in your latest screenshot won’t work for two reasons.

  1. YES and NO are components. The will never be found in the name of the component clicked by the mouse (which is a strong)

  2. If you want the answer to sometimes be YES and sometimes be NO then you have to use a variable, like the one I suggested in my last post.

Thanks.
Lets see if I got you correctly:
I should remove the incorrect column from the excel file and just keep the right answers. Which means if they give different answers that I have in excel file, then they will receive a error feedback. Right?

I also made some changes in the codes without any changes in excel file, but I dont know what is the issue.