# How can you block the key "Escape"

**URL:** <https://discourse.processing.org/t/how-can-you-block-the-key-escape/6765>\
**Category:** Coding Questions\
**Created:** [December 19, 2018, 7:42pm UTC](https://discourse.processing.org/t/how-can-you-block-the-key-escape/6765 "2018-12-19T19:42:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fritzpal](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@fritzpal](https://discourse.processing.org/u/fritzpal)\
**Post date:** [December 19, 2018, 7:42pm UTC](https://discourse.processing.org/t/how-can-you-block-the-key-escape/6765/1 "2018-12-19T19:42:02Z")

</div>

Hi,  
does somebody know how to block processing from closing the sketch when you press escape?

I tried this but it did not work:

```auto
void draw(){
if(key == ESC)key = 0;
}

```

Thank you

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [December 19, 2018, 7:50pm UTC](https://discourse.processing.org/t/how-can-you-block-the-key-escape/6765/2 "2018-12-19T19:50:01Z")

</div>

Hi! That code should be inside `void keyPressed()`, not inside `void draw()`. Then it works.

---

<div class="post-metadata">

**Author:** ![fritzpal](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@fritzpal](https://discourse.processing.org/u/fritzpal)\
**Post date:** [December 19, 2018, 7:57pm UTC](https://discourse.processing.org/t/how-can-you-block-the-key-escape/6765/3 "2018-12-19T19:57:41Z")

</div>

Thank you so much:grinning:
