//XMAL 代码

        <Window x:Class="GXYLaundry_RegOnline.RegisterWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         MouseLeftButtonDown="Window_MouseLeftButtonDown" 

        KeyDown="Window_KeyDown" >

        //后台方法

        private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Escape)  //按esc退出
            {
                e.Handled = true;
                this.Close();
            }
        }

更多推荐