Setting feedback display to one second

Hello there!

I have programmed an experiment where participants receive feedback based on their button presses, with correct answers resulting in text turning green and incorrect answers resulting in red. However, I want to limit the feedback to exactly one second, rather than allowing it to continue until the end of the routine. I am are aware that creating separate routines for logging responses and giving feedback is an option, but I would very much prefer to implement both in a single routine to better suit my current experimental setup.
The feedback in general works well, however, the timer does not seem to work, as the routine always continues until it’s set time (of 4 seconds) and not until button press + 1s.

This is the JS code I habe so far:

# Each frame:
startTime = 0;
if ((resp_test_inst_2.keys === "left")) {
    if (resp_test_inst_2.corr) {
        response_sec_question_training.contrast = 1;
        response_sec_question_training.color = "green";
        startTime = new util.Clock();
    } else {
        if ((resp_test_inst_2.corr === 0)) {
            response_sec_question_training.contrast = 1;
            response_sec_question_training.color = "red";
            startTime = new util.Clock();
        }
    }
}
if ((resp_test_inst_2.keys === "right")) {
    if (resp_test_inst_2.corr) {
        response_sec_question_training_2.contrast = 1;
        response_sec_question_training_2.color = "green";
        startTime = new util.Clock();
    } else {
        if ((resp_test_inst_2.corr === 0)) {
            response_sec_question_training_2.contrast = 1;
            response_sec_question_training_2.color = "red";
            startTime = new util.Clock();
        }
    }
}
if ((startTime >= 2)) {
    continueRoutine = false;
}

# End Routine 
startTime = 0; // to reset the startTime again

I am aware that I am about to mess with the Each frame timings that are built into the builder generated code, so I am very thankful for any advice solving my issue.

Many thanks!