# Refresh Run - Key Pressed

**URL:** <https://discourse.processing.org/t/refresh-run-key-pressed/34848>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [January 26, 2022, 1:37pm UTC](https://discourse.processing.org/t/refresh-run-key-pressed/34848 "2022-01-26T13:37:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Copious-plains](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@Copious-plains](https://discourse.processing.org/u/Copious-plains)\
**Post date:** [January 26, 2022, 1:37pm UTC](https://discourse.processing.org/t/refresh-run-key-pressed/34848/1 "2022-01-26T13:37:54Z")

</div>

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.

```auto
< 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 
 
  
  {
  }  

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 26, 2022, 8:00pm UTC](https://discourse.processing.org/t/refresh-run-key-pressed/34848/2 "2022-01-26T20:00:05Z")

</div>

hi

try to use this [keyPressed / Reference](https://processing.org/reference/keyPressed.html)

with this code

```auto

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");
 } 
 

```
