Detect when two keys are pressed at the same time

后端 未结 4 1162
北海茫月
北海茫月 2020-12-10 07:18

I have no idea how do this.

I know only how do detect one key:

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys         


        
4条回答
  •  鱼传尺愫
    2020-12-10 07:49

    You have to keep track of keydown/keyup events, and keep a list of all the keys that are currently "down". The keyboard handler can only trigger on individual keys, and it's up to your code to detect/keep track of which ones are down, and if those individual keydown events are close enough to each other to be counted as "together".

提交回复
热议问题