Refresh Run - Key Pressed

Hi,
I have a problem. I want to write a code that will refresh an image (refresh the Run) after every key pressed and export/save image as a for example TIFF. or PNG. I’ve got this for now.
Do you know how should I do it properly?
Thank you for your help.

< void keyPressed()  ///← to jakbysy chcieli zapisac w dowolnym momencie, wtedy wkladamy w funkcje z nacisnieciem czegos
{
  {
    if (keyPressed == true) { // If the key is pressed,
  
     save("nazwa_"+day()+"_"+month()+"_"+hour()+"_"+minute()+"_"+second()+".png");
  } else 
 
  
  {
  }  

hi

try to use this keyPressed / Reference

with this code


void setup(){
size(640,200);
  textSize(44); 
//text(day()+"/"+month()+"/"+year()+" - "+hour()+":"+minute()+":"+second(),width/6,height/4);
 }
 void draw(){
background(0);
   text(day()+"/"+month()+"/"+year()+" - "+hour()+":"+minute()+":"+second(),width/6,height/4);
save("time.tif");
 }