Win.CodeNavi.frmMain.frmMain_KeyPress C# (CSharp) Method

frmMain_KeyPress() private method

This catches the escape to exist the app
private frmMain_KeyPress ( object sender, KeyPressEventArgs e ) : void
sender object
e KeyPressEventArgs
return void
        private void frmMain_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (Char)System.Windows.Forms.Keys.Escape)
            {
                if (this.MdiChildren.Count() == 0)
                {
                    if (MessageBox.Show("Are you sure you wish to exit?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Application.Exit();
                        e.Handled = true;
                    }
                }
            }
        }