---
title: "Close windows form on click escape key in C#"  
description: "Close windows form on click escape key in C#"  
author: "Anonymous User"  
published: 2013-10-07  
updated: 2013-10-08  
canonical: https://www.mindstick.com/forum/1644/close-windows-form-on-click-escape-key-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Close windows form on click escape key in C#

How to [close](https://yourviews.mindstick.com/story/1687/rubbing-hands-close-up-benefits) a [windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) [form](https://www.mindstick.com/forum/6/multi-form-mfc-application) on [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) the [escape](https://answers.mindstick.com/qa/98969/jungle-run-temple-escape-is-better-than-temple-run) key using C#?

## Replies

### Reply by Anonymous User

Firstly you need to handle the Form Key Down event and then check the event key code is equal to Keys.Escape and the in the true section you can write the form close statement.

```
private void Form_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Escape)
    {
        this.Close();
    }
}
```


---

Original Source: https://www.mindstick.com/forum/1644/close-windows-form-on-click-escape-key-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
