Please, help me, really easy question

With this easy code:

void setup () {
  size(500, 500);
  background(255, 255, 255);
}

void draw() {
	if(keyPressed){
		if(key=='a'){
    rect(20, 20, 50, 50);
		}
  }
}

Why the square didn’t disappear when I stop clicking “a”???
If you can send me how to do it I will preciate.

1 Like

Hello,

Look at the reference for setup(), draw() and background().

Reference:
https://processing.org/reference/setup_.html
https://processing.org/reference/draw_.html
https://processing.org/reference/background_.html

:)

1 Like

Hi @Carlos138

Try this … :slight_smile:

void setup () {
  size(500, 500);
}

void draw() {
   background(255, 255, 255);
   if(keyPressed) {
       if(key=='a') {
             rect(20, 20, 50, 50);
        }
    }
}

Cheers
—mnse

2 Likes