7.2 How can I tell if an ALT, Shift or CTL key is pressed without catching an event?


Use the static property Control.ModifierKeys.

     Console.WriteLine(Control.ModifierKeys);
     if( (Control.ModifierKeys & Keys.Shift) != 0)
          Console.WriteLine("the shift key is down");
     if( (Control.ModifierKeys & Keys.Alt) != 0)
          Console.WriteLine("the alt key is down");
     if( (Control.ModifierKeys & Keys.Control) != 0)
          Console.WriteLine("the control key is down");

© 2001-2010 Copyright Syncfusion Inc. All rights reserved.  |  Privacy Policy  |  Contact  |  Sitemap