From: http://blog.csdn.net/chenshizero/article/details/2173443
先将窗口的KeyPreview设置为true,然后再在窗口的KeyPressUp事件中写代码就可以了
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if(e.KeyValue == 27)
//if (e.KeyData == Keys.Escape)
Application.Exit();
}