Store correct answer (keys) not working

If this template helps then use it. If not then just delete and start from scratch.
PsychoPy version v2022.2.4
**Standard Standalone? yes

I use a keyboard component where I specify a few numerical values as ‘allowed keys’. It works well and is saved well in the .csv.

However, I noticed that the ‘store correct’ function does not seem to be working properly, and interprets and saves all responses as wrong (i.e., 0) even if the correct button was pressed.
There is the ‘store correct’ input box in the builder. I experimented with different ways of defining what is the correct response (namely keypress ‘2’) by putting: 2, ‘2’, $2, $‘2’, etc.
I found on this forum that all responses being saved as wrong (as 0) used to be a problem with previous PsychoPy versions (e.g., Correct response variable not recognised for new experiment with new version: 'key_resp.corr' always FALSE - #15 by TParsons).
But I believe this was resolved already, and I am using the new 2022.2.4 version.

  1. Is it possible to have two alternative responses defined as ‘correct’ response? In my experiment, the allowed keys are 1,2,3,4, and a correct response would be 3 OR 4 (a press ends a routine, participants are instructed to press one button, and as long as they press 3 OR 4 I wish to store it as correct). Input such as 3 or 4 does not work. But I think it is necessary to resolve problem 1) first.

Would you have any suggestions to my question 1) and subsequently 2? Please note that the ‘store correct’ does not work even if I define just one correct response (e.g., just 3). I thought the problem was with wanting to have two options for correct response, but it does not work for one either.

Thank you in advance!

Hello KatKat

to use the Correct answer feature of a keyboard-component you need to specify a column in your Excel-file. In the example below I specify $corrAns in Correct Answer and the Excel-file has a column name corrAns. This column contains the correct key, the participant has to press. In the example it is a j. AFAIK, you can specify as many correct keys as you want but only one per trial. So another correct key in this experiment is a f.



If you want more one correct key in a trial, you either need some code in PsychoPy or compute the correctness of your answer during data analysis.

Best wishes Jens

Dear Jens,

Thank you so much for your kind and exhaustive reply. It is helpful, and following your advice I will compute correctness on the data analysis stage then.

It is quite interesting that a Excel column needs to be added, rather than input being taken from an Excel OR straight from the line (like for the ‘allowed keys’) for example.

Thank you again! All the best.

Kind regards,


I am having the exact same problem in my experiment except I am using an older version of Psychopy (2021.1.2). The problem is I have already created my entire experiment without using an excel file. Is there no way of storing multiple correct answers without using an excel file?

Thanks in advance

1 Like

In addition, storing one correct response works fine (using the syntax $‘2’ for example). But I’ve tried multiple times with multiple variables and I always get an output of 0 for correct response in the data sheet.

Examples of syntax I’ve tried:
2 4 5
2, 4, 5
$‘2’,‘4’,‘5’ → gives me an error and ends the experiment

1 Like

As afterthoughts from @JensBoelte and @vhetgui,
I am still surprised that for me (Psychopy v2022.2.4) the ‘store correct’ input box does not even work when inputting just one correct key (always saves response as incorrect/0 in the .csv file).
It seems like at least a single key should be accepted straight from the input box to evaluate whether the response was correct, without creating an additional column in the .csv.
Especially given that it works for @vhetgui in a different version.

Could there be a deeper reason for why Psychopy v.2022.2.4 does not seem to accept input from the ‘store correct’ input box? Was it an intentional change made for v.2022.2.4?

Hello vhetgui

you need some code to determine the correctness of the answer. Something along those lines.

if key_resp.keys == '1':
    key_resp.corr = 1
elif key_resp.keys == '2':
    key_resp.corr = 1
    key_resp.corr = 0

I am not sure if you have to store key_resp.corr explicitly or if PsychoPy stores it for you automatically. If you have to store it explicitly, add

thisExp.addData("key_resp.corr", key_reps.corr)

Best wishes Jens

Dear @JensBoelte

Thank you for your kind response. This absolutely makes sense.

However, I am still wondering whether it was a change introduced to Psychopy 2022.2.4 that even if we just want to have 1 correct key, it still does not work simply by inputting the key (e.g., 1 or ‘1’,. etc.) in the ‘store correct’?

This function is there, and it should work without code component or Excel.
It seems like it was a recurring issue in the past (that the correctness was not working in the Builder), therefore I wonder if this is an issue that has yet again returned in the new v2022.2.4. I think it would be important to determine.

Because before I will go to code component, I would like to ensure that the most basic functionalities work properly.

Thank you.