WPF 键盘事件

private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyStates==Keyboard.GetKeyStates(Key.Escape))
{
this.Close();
}
}

原文地址:https://www.cnblogs.com/LCLBook/p/11345717.html