# I need a shortcut for stopping sketch in Processing

**URL:** https://discourse.processing.org/t/i-need-a-shortcut-for-stopping-sketch-in-processing/39642
**Category:** Beginners
**Created:** [November 9, 2022, 11:59am UTC](https://discourse.processing.org/t/i-need-a-shortcut-for-stopping-sketch-in-processing/39642 "2022-11-09T11:59:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![abdu](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@abdu](https://discourse.processing.org/u/abdu)
#### Post date: [November 9, 2022, 11:59am UTC](https://discourse.processing.org/t/i-need-a-shortcut-for-stopping-sketch-in-processing/39642/1 "2022-11-09T11:59:55Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

![فهرس](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/6/f62227f6c58de3ce3effb6ee514a91eaaf2c5b61.png)

I want to create a custom shortcut for stopping the sketch because there is no shortcut for that  
is there any code I can use in the program for that

---

<div class="post-metadata">

### Author: ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)
#### Post date: [November 9, 2022, 12:10pm UTC](https://discourse.processing.org/t/i-need-a-shortcut-for-stopping-sketch-in-processing/39642/2 "2022-11-09T12:10:42Z")

</div>

Just press on your keyboard :

> ESC

---

<div class="post-metadata">

### Author: ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)
#### Post date: [November 9, 2022, 12:54pm UTC](https://discourse.processing.org/t/i-need-a-shortcut-for-stopping-sketch-in-processing/39642/3 "2022-11-09T12:54:19Z")

</div>

Hello @abdu

There are a few nice suggestions in this thread:

> [@How to freeze a draw loop?](https://discourse.processing.org/t/how-to-freeze-a-draw-loop/2741):
>
> I have a draw loop that makes a new graphic each time. I want to be able to pause the loop by clicking the mouse when I see a graphic that I like. But everything I’ve tried fails to stop on the current frame. It’s always the next frame, or a later one, no matter how slow the frame rate. For example, if (mousePressed == true) { delay(20000); } pauses things for 20 seconds, but it seems to take a frame or two until things stop. I haven’t found any info that addresses this sort of thing…I’m doin…

🤓

---

<div class="post-metadata">

### Author: ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)
#### Post date: [November 11, 2022, 12:50am UTC](https://discourse.processing.org/t/i-need-a-shortcut-for-stopping-sketch-in-processing/39642/4 "2022-11-11T00:50:58Z")

</div>

Just hit esc on the keyboard, sometimes it doesnt work unless you click the screen first, to solve that issue put

```auto
surface.setVisible(true);

```

in the void setup function  
not sure if the surface is even needed in the newer version as im still using 3.54
