hello everyone.
i want to press the enter key and than change the color of the screen to green for 1 second. After that 1 second it should go back to white. And I want to do that in the keyPressed() method.
Instead in draw() you use a variable bkCol in the background command
background (bkCol);
Before setup () say color bkCol = background_color; or so
On Enter Key
Now, in the enter key section you change bkCol=success_color; so we change the background which is displayed in draw().
Here you also say timer=millis(); which stores the current milliseconds.
Before setup() please add int timer=0;
Reset
At the end of draw() say
// evaluate if one second is over
if(millis()-timer >= 1000){
bkCol=background_color; // reset color background_color
}
The program is just running on, draw() runs 60 times per second. And we just change the variable for the background.
And we reset the color after a timer is over.
I hope this helps.
Hey, and welcome to the forum!
Great to have you here!