I have tried the following:
private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if ((Keys) e.KeyValue == Keys.Escape)
You need add this to event "KeyUp".
private void Form1_KeyUp(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.Escape) { this.Close(); } }