'right' key not recognised as correct response

I am building a simple experiment of working memory, where 2 sets of three letters are presented with a distractor between them, and the participant has to answer ‘left’ if one of the letters was present before or ‘right’ if all letters are new.
For this purpose I have an xlsx file with the two sets of letters, the distractor and whether the answer is yes or no, coded with ‘left’ and ‘right’ under the variable corrAns. Everything works smoothly, but for some reason the output only recognises ‘left’ answers as right.
More specifically: when there is a mismatch between the answer given and the correct one, key_target.corr is 0; when the correct answer is ‘left’ and the participant presses ‘left’ key_target.corr is 1; when the correct answer is ‘right’ and the participant presses ‘right’ key_target.corr is 0.
I tried changing the order, adding one more key, but the issue keeps presenting itself.
Any ideas?

Hi @blarosa, if you only have ‘right’ as a key option, does it recognize it as the correct answer when it should? If you swap ‘right’ with ‘space’ for instance, and adjust the correct answer to be ‘space’ in your conditions file, what happens?

@sawal thanks a lot for the suggestion! I just tried replacing ‘right’ with ‘space’ and now it’s able to recognise it as the right answer. Do you have any idea on why that is?

Okay, that was just to make sure it wasn’t something in your conditions file or something and is more specific to the right key.

I’ve attached a working example-- when “2” is presented, the correct answer is “right”, and key_resp.corr returns 1.

Can you test it on your system?

leftRight.psyexp (6.6 KB) conditions.csv (65 Bytes)

With your file it’s able to recognise ‘right’ as the right answer. I had also made a stroop task as practice some time ago and it worked just fine. It’s just this task that has issues.

Two other things I would try is 1. making sure the correct condition files is being called, and 2. check the key_resp.keys variable in the data file, as that records what key was pressed to make sure it’s recording the correct key being pressed.

With this sort of issue, it is worth opening your .csv file in a plain text editor (not in Excel or another spreadsheet). It might be that there is an invisible character that has crept in that you can’t see otherwise (e.g. it might not be 'right' in a cell, but 'right ').

You could instead insert some (temporary) debugging code, e.g. insert a code component from the “custom” component panel, and put something like this in the “end routine” tab:

print('Trial: ' + str(your_loop_name.thisN)
print('|' + corrAns + '|')
print(corrAns == key_target.keys())

You were indeed right! There was a space after ‘right’ in the excel file, I don’t know why I haven’t thought about it.
Thank you so much!