keyPressed to change image color, help!

Hey there! I was tasked to recreate the bouncing DVD logo screen - however I’m meant to make it so that when a key is pressed, the image changes a random color.

I’ve tried a bunch of different combinations, and can’t seem to make anything stick :confused:

I’d be grateful for any advice. Thank you!

My p5 file:

You may try out method p5.Image::tint() or even p5.Image::filter():

if you’re confused about the activation and not the changing image color

“when a key is pressed”

you want to look at the function

function keyPressed() {
// Code to activate here

you can then use a if statement to check which key was pressed:

function keyPressed() {
  if (keyCode === LEFT_ARROW) {
    // Do this
  } else if (keyCode === RIGHT_ARROW) {
    // Do that

Here is also the reference link: Key Pressed Ref