keyPressed Help

Is this your entire code?

well to have a animation you need to have setup() and draw() - see the first text tutorials

E.g.: The section Hello mouse here: https://www.processing.org/tutorials/overview/

also, it helps to have background at the beginning of draw()

Also repeat bras2 = 305; because it won’t go back to its initial value automatically

float bras2 = 305;

void setup() {
  size(800, 800);
  background(0);
}

void draw() {

  background(0);

  if (keyPressed == true ) {
    bras2 = 255;
  } else {
    bras2 = 305;
  }
  fill(#E3DBC3);
  rectMode(CENTER);
  rect(365, bras2, 10, 80);
  rectMode(CENTER);
  rect(235, bras2, 10, 80);
}
2 Likes