How to detect multiple keys down onkeydown event in wpf?

前端 未结 3 977
走了就别回头了
走了就别回头了 2020-12-03 23:28

I don\'t want to detect any double key combination, so solutions like

if(Keyboard.IsKeyDown(specificKey)){

}

won\'t work, unless of cours

3条回答
  •  再見小時候
    2020-12-03 23:35

    You should use key modifier in combination with your customized key

    if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) // Is Alt key pressed
    {
      if (Keyboard.IsKeyDown(Key.S) && Keyboard.IsKeyDown(Key.C))
      {
        // do something here
      }
     }
    

提交回复
热议问题