Ctrl key with Mouse Event.

  • Thread starter Thread starter Phil Jones
  • Start date Start date
P

Phil Jones

I think I'm missing something REAL basic - but...

How do I determine if the CTRL key is down when a mouse-event occurs.

I can't see anything on the [MouseEventArgs].

Thanks everyone
===
Phil
 
Hi Phil,

Unlike the KeyEventArgs there is no direct access to the modifier keys
ctrl, alt, shift. However, not to worry, because there is this handy
static method called Control.ModifierKeys that you can use at any time.

if(e.Button == MouseButtons.Left && Control.ModifierKeys == Keys.Control)
// left mousebutton is clicked while the Ctrl key is down

If you want combinations like ALT+SHIFT just do a bitwise comparison with
Control.ModifierKeys.
You can do the same thing in a Key event using Control.MouseButtons :)
 
Ahh sweet- new it had to be something like that.

Very good - thanks Morten!
===
Phil
 
Back
Top