c# - How to make a form close when pressing the escape key? - Stack Overflow

PHOTO EMBED

Thu Nov 02 2023 22:29:10 GMT+0000 (Coordinated Universal Time)

Saved by @amman

private void Form_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Escape)
    {
        this.Close();
    }
}
content_copyCOPY

https://stackoverflow.com/questions/3526752/how-to-make-a-form-close-when-pressing-the-escape-key