首先设置KeyPreview = true;
Ctrl+V
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.V) { MessageBox.Show("Test"); }
Ctrl+Alt+B
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.Alt) { if (e.KeyCode == Keys.B) { // Your code goes here } } }
Ctrl+H+E
Keys lstKeyPressed; private void Form1_KeyDown(object sender, KeyEventArgs e) { if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.E && lstKeyPressed == Keys.H) { Console.WriteLine("Ctrl+H+E");// 仅实现Ctrl+H+E,Ctrl+E+H不触发 } lstKeyPressed = e.KeyCode; }