[转]触发窗体事件(例如按Esc关闭窗体),WinForm

设置窗体属性KeyPreview=True。
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
  if (e.KeyData == Keys.Escape)Application.Exit();
}

原文地址:https://www.cnblogs.com/runliuv/p/3210597.html