rik
rik

Reputation: 1299

Detecting Control Shift and W

i can detect control and w using

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

However it doesnt seem to be 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?

Upvotes: 3

Views: 2381

Answers (1)

BoltClock
BoltClock

Reputation: 723468

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)

Upvotes: 7

Related Questions