set the form’s KeyPreview property to true, and add this override to the Form code:
protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (e.KeyCode == Keys.Escape) this.Close(); }
set the form’s KeyPreview property to true, and add this override to the Form code:
protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (e.KeyCode == Keys.Escape) this.Close(); }