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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top