首先要设置主窗体KeyPreview为true,可直接在属性中进行设置,
或者在窗体加载中设置: this.KeyPreview = true;
然后添加窗体KeyDown事件,如下:
class="dp-c" start="1">
- private void FrmMain_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Alt && e.Shift && e.Control && e.KeyCode == Keys.S)
- {
- MessageBox.Show("我按了Control +Shift +Alt +S");
- }
- }