This question already has answers here:
How to use multiple modifier keys in C#
                                
                                    (8个答案)
                                
                        
                                5年前关闭。
            
                    
我有问题。如果我按下一个键,就可以得到事件,例如:

if (e.KeyCode == Keys.F4)
            {
                Method();
            }


如果我按两个键怎么办?例如输入+ F4?

最佳答案

    FormLoad()
{
   this.KeyPreview = true;
   this.KeyDown += new KeyEventHandler(Form1_KeyDown);
}

void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            //Works for Ctrl+F4
            if (e.Control && e.KeyCode == Keys.F4)
            {
                //Do something
            }
        }


看看是否适合您。

10-08 11:23