How can i move the right rectangle using the up and down keys

i’ve started like two days ago and i cant figure out how top move things using the keys.
this is what i got so far a bit messy but it works.

 int x = 320;
 int y = 240;
 int dx = +10;
 int dy = -5;
 int rx = 600;
 int ry = 160;
 int lx = 40;

 
 
void setup(){
  size(640, 480);
}
void draw(){
background(0, 0, 0);
  ellipse(x, y, 50, 50);
  x = x + dx;
  y = y + dy;
  if(x +25 > width || x -25 < 0) {
     dx *= -1;
  }
  if(y +25 > height || y -25 < 0) {
    dy *= -1;
  }
  rect(rx, ry, 20, 160);
  rect(lx, y - 80, 20, 160);
}

look at this example

https://www.processing.org/reference/keyCode.html

and change your ly accordingly