P5js I want code to run for a susstained ammount of time after keyIsPressed

I am a complete beginner and I am working inside a custom p5js framework for a school project. We are working on a clock.

Basically, I want a piece of code to stay active for ~5 seconds after using the keyIsPressed feature. I’ve tried just about every solution I can possibly think of, for loops, while loops. Even my teacher hasn’t been able to help me solve this.

The kicker is we are not allowed to use the native p5js seconds. Since we are working inside the clock framework for school they have made custom hour, minute, second objects. I feel like these will be the key but I just can figure it out.

  if((keyIsPressed === true) &&  (keyCode === ENTER)) {
  fill(255, 0, 0);
  ellipse(700, 250, 300, 300);
  }

Is there a way where I can sustain the code inside this if statement instead of it just running while the key is held?

This is probably a silly question but I just couldn’t find an answer anywhere, Thank you in advance.