I'm trying to show a zoomed in overlay on an image when mouse over and shift key pressed.
The problem is that user might have pressed the shift key before even the window has focus, so KeyDown monitoring is not a solution.
Is there a way to access modifier key states during mouse events? In Java for example the mouse event contains flags for modifier keys, not so in .NET.
The mouseEvent shiftKey property is used to define whether the shift key is pressed or not. It is a boolean value. When the shift key is pressed then on click of the mouse left button, it returns true and if the shift key is not pressed then it returns false.
Definition and Usage. The shiftKey property returns a Boolean value that indicates whether or not the "SHIFT" key was pressed when a key event was triggered. Note: This property is read-only.
Try using the Control.ModifierKeys property:
if ((Control.ModifierKeys & Keys.Shift) != Keys.None)
{
// do my stuff
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With