# P5.js Redo Tool

**URL:** <https://discourse.processing.org/t/p5-js-redo-tool/38095>\
**Category:** Coding Questions\
**Created:** [July 25, 2022, 8:34am UTC](https://discourse.processing.org/t/p5-js-redo-tool/38095 "2022-07-25T08:34:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![courserastudent16](https://avatars.discourse-cdn.com/v4/letter/c/977dab/32.png) [@courserastudent16](https://discourse.processing.org/u/courserastudent16)\
**Post date:** [July 25, 2022, 8:34am UTC](https://discourse.processing.org/t/p5-js-redo-tool/38095/1 "2022-07-25T08:34:17Z")

</div>

Hello,  
I hope everyone is doing well.

I’m trying to create a redo tool using P5.js.  
I’m using a constructor function to make the tool.  
What should I add to this function below? I want the redo button to work shapes.

Thank you

```auto
select("#redoButton").mouseClicked(function(){
         
    });

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/d/4d2a7efeef6d83576b75dbf2d031897cb71617e9.png)

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [July 25, 2022, 9:30am UTC](https://discourse.processing.org/t/p5-js-redo-tool/38095/2 "2022-07-25T09:30:22Z")

</div>

Pretend you are the redo button. When you get clicked, your job is to redo the last change that was undone.

How are you going to know what the undone change was change was?!? Thankfully, the undo action has a data structure that’s tracking all the changes. Hopefully it remembers the changes it’s undone! If you can make use of that information, you can simple draw the last shape again.

---

<div class="post-metadata">

**Author:** ![courserastudent16](https://avatars.discourse-cdn.com/v4/letter/c/977dab/32.png) [@courserastudent16](https://discourse.processing.org/u/courserastudent16)\
**Post date:** [July 25, 2022, 10:29am UTC](https://discourse.processing.org/t/p5-js-redo-tool/38095/3 "2022-07-25T10:29:08Z")

</div>

I tried this, but it didn’t work.

```auto
let fillVal = 255;

function draw() {
  fill(fillVal);
  if (keyIsDown(CONTROL) && keyIsDown(90)) fillVal = 0;
  rect(25, 25, 50, 50);
}

```
