# (NOOB) How to keep a shape on screen after I release the mouse click?

**URL:** <https://discourse.processing.org/t/noob-how-to-keep-a-shape-on-screen-after-i-release-the-mouse-click/27712>\
**Category:** Coding Questions\
**Created:** [February 10, 2021, 7:57pm UTC](https://discourse.processing.org/t/noob-how-to-keep-a-shape-on-screen-after-i-release-the-mouse-click/27712 "2021-02-10T19:57:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abo\_shack](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@abo\_shack](https://discourse.processing.org/u/abo_shack)\
**Post date:** [February 10, 2021, 7:57pm UTC](https://discourse.processing.org/t/noob-how-to-keep-a-shape-on-screen-after-i-release-the-mouse-click/27712/1 "2021-02-10T19:57:01Z")

</div>

Hey guys, super noob here. I have a simple code where when I left click it produces a red dot, and when I right click it produces a blue dot. When I release my click the dot disappears. How do I get the dot to stay on the screen?

void setup() {  
size (500, 500);  
background (150, 100, 50);  
}  
void draw(){  
if (mousePressed && (mouseButton == LEFT)) {  
stroke (255, 0, 0);  
fill (255, 0, 0);  
ellipse (mouseX, mouseY, 5, 5);

} else if (mousePressed && (mouseButton == RIGHT)) {  
stroke (0, 0, 255);  
fill (0, 0, 255);  
ellipse (mouseX, mouseY, 5, 5);

} else {  
background (150, 100, 50);  
}

}

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [February 10, 2021, 8:03pm UTC](https://discourse.processing.org/t/noob-how-to-keep-a-shape-on-screen-after-i-release-the-mouse-click/27712/2 "2021-02-10T20:03:18Z")

</div>

> [@abo\_shack](#):
>
> } else {  
> background (150, 100, 50);  
> }

remove this. Add something like

```auto
<your current code>
<...>
void keyPressed() {
   if(key == ' ') background(150,100,50) //reset screen if you press space
}

```

here is the new code:

> **Code**
>
> ```auto
> void setup() {
> size (500, 500);
> background (150, 100, 50);
> }
> void draw() {
> if (mousePressed && (mouseButton == LEFT)) {
> stroke (255, 0, 0);
> fill (255, 0, 0);
> ellipse (mouseX, mouseY, 5, 5);
> } else if (mousePressed && (mouseButton == RIGHT)) {
> stroke (0, 0, 255);
> fill (0, 0, 255);
> ellipse (mouseX, mouseY, 5, 5);
> }
> }
> void keyPressed() { 
> if (key == ' ') background(150, 100, 50);
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![abo\_shack](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@abo\_shack](https://discourse.processing.org/u/abo_shack)\
**Post date:** [February 10, 2021, 8:05pm UTC](https://discourse.processing.org/t/noob-how-to-keep-a-shape-on-screen-after-i-release-the-mouse-click/27712/3 "2021-02-10T20:05:48Z")

</div>

Thank you so much! Very new to this lol but this fixed it

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [February 10, 2021, 8:06pm UTC](https://discourse.processing.org/t/noob-how-to-keep-a-shape-on-screen-after-i-release-the-mouse-click/27712/4 "2021-02-10T20:06:25Z")

</div>

Glad to help!  
Have a fun learning!
