Feedback appearance and duration according to correct key response

Hi, I’m new to Psychopy and coding and trying to create an online version of an IAT.

PsycoPy Version: v2022.2.4

I have completed all sections and components besides the feedback.

I would like for feedback to appear on the trial screen (I addressed this by adding the feedback components to the trial routine) with all other components when a trial is incorrect only and for the participant to not be able to move on to the next trial until the correct answer is coded.

I found a way for feedback to only appear when the incorrect key_resp is made however my feedback appears at the start of my trial and I am struggling with the duration only being until the trial is over (e.g. on builder I attempted to set the duration to $key_resp.corr, but this did not work and it continues to display for whatever my selected duration is at the start of the trial)

The code I currently have is as follows:

Begin Routine
if key_resp.corr:
fb_text = ‘’
fb_col = ‘’
fb_text = ‘x’
fb_col = ‘red’
print(“keys: %r” %(key_resp.keys))
print(“corrAns: %r” %(corrAns))
print(corrAns == key_resp.keys)

The “except” section addresses an issue I was having with key_resp.corr not being displayed in the data file.

Is there something else I need to do or a specific piece of code I need to input to achieve my desired outcome?
(I read the ‘Building Experiments in PsychoPy’ book but I struggled to find something to address my specific issue)