参考:http://blog.csdn.net/zhensoft163/article/details/4239796
方法1:使用窗体的 KeyDown 事件
1 private void Form1_KeyDown(object sender, KeyEventArgs e)
2 {
3 if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control)
4 MessageBox.Show("Ctrl + A");
5 }
方法2:重写 ProcessCmdKey 方法(不受光标影响):
1 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
2 {
3 if (keyData == (Keys.Control | Keys.A | Keys.Shift))
4 {
5 MessageBox.Show("Ctrl + A");
6 }
7 return base.ProcessCmdKey(ref msg, keyData);
8 }
方法3:重写 ProcessDialogKey 方法(受光标影响):
1 protected override bool ProcessDialogKey(Keys keyData)
2 {
3 if (keyData == (Keys.Control | Keys.A | Keys.Shift))
4 {
5 MessageBox.Show("Ctrl + A");
6 }
7 return base.ProcessDialogKey(keyData);
8 }