Please tell me how to save the Processing file as PNG

please format code with </> button * homework policy * asking questions

Sorry, this problem may be a little stupid. I can’t find very detailed steps on the Internet. I tried a code, but I don’t know why it doesn’t work. Please help me and tell me other methods or my coding errors.

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

void draw() {

strokeWeight(3);
ellipse(mouseX, mouseY, 100, 100);

}
void keyPressed() {
if (key == ‘s’ || key == ‘S’) saveFrame(“#####.png”);
}

Your code runs ok on my Mac, as is, after changing the curly quotes which apparently become altered with a copy/paste to the editor. The saved .png file is in the sketch folder. An alternate method would be to place if (keyPressed) {…} inside of draw() function. See https://processing.org/reference/key.html.

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

void draw() {

  strokeWeight(3);
  ellipse(mouseX, mouseY, 100, 100);

  if (keyPressed) {
    if (key == 's' || key == 'S') saveFrame("#####.png");
  }
}