Feedback Routine in 2back experiment

OK, yes, that code is for the general case where stimuli are randomised and so the n-back values need to be calculated. If you have sequential conditions and your own “correct” variable, then your problem is indeed simpler.

Part of the reason why your code above is failing is that you are referring to the keyboard component itself (key_resp_4) and not one of its specific attributes (like key_resp_4.corr or key_resp_4.keys), etc. At the moment you’re kind of asking “is my keyboard the space bar?”

If you don’t have any luck, please provide a screenshot of your keyboard component settings, and the text of your code (i.e. it’s easier to suggest changes to code if you paste in the code itself, rather than a screenshot, which can’t be copied from), and please: