开发者

Detecting Control Shift and W

开发者 https://www.devze.com 2023-03-17 15:38 出处:网络
i can detect control and w using if (Keys.W == (Keys)vkCode && Keys.Control == Control.ModifierKeys)

i can detect control and w using

 if (Keys.W == (Keys)vkCode &&
     Keys.Control == Control.ModifierKeys)

However it doesnt seem to be开发者_如何学Go the case that it detects correctly when adding

 if (Keys.W == (Keys)vkCode &&
     Keys.Control == Control.ModifierKeys &&
     Keys.Shift= Control.ModifierKeys)

Is there anything in particular i need to do to check for 3 keys being pressed opposed to 2?


The ModifierKeys property is a bitmask, so you need to do a bitwise OR on both the Control and Shift values.

 if (Keys.W == (Keys)vkCode &&
     (Keys.Control | Keys.Shift) == Control.ModifierKeys)
0

精彩评论

暂无评论...
验证码 换一张
取 消