private void frmMain_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(27)) { ToggleState(); } }