Hello there!
Is there any way you can post your full code? It’s difficult to figure out the initial setup without knowing the rest of the program. If for some reason you don’t want to post your full code (it is highly recommended that you do), I would say look at the standalone methods keyPressed(){} and keyReleased{}. Also, if you want the background to be white regardless, try putting the background(255) just after the “void draw(){” and not in any parenthetical statements. This will set the background to 255 every time the draw loop iterates, as the first thing in the loop.
EDIT: You posted the full code! Sorry.