键盘快捷键不起作用

问题描述:

private void MDIParent1_KeyDown(object s, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode.ToString() == "q")
            {
                MessageBox.Show("welcome");
                this.KeyPreview = false;
            }
        }


当我按ctrl+q时,消息框应该显示.,我使用了上面的编码,但是它不起作用


when i press ctrl+q, message box should show., i used above coding but its not working

将keyPreview属性设置为true
并且代码应为
Set the keyPreview property to true
and code should be
e.KeyCode.ToString() == "Q"