title: C# - Detecting if the SHIFT key is held when opening a context menu
body: <p>In my C# application I want to display a context menu, but I want to add special options to the menu if the SHIFT key is being held down when the context menu is opened.</p>
  
  <p>I'm currently using the <code>GetKeyState</code> API to check for the SHIFT key.  It works fine on my computer but users with non-English Windows say it doesn't work at all for them.</p>
  
  <p>I also read that in the Win32 API when a context menu is opened there's a flag that indicates in the menu should show <code>EXTENDEDVERBS</code>.  In C# the <code>EventArgs</code> for the <code>Opening</code> event doesn't contain (from what I can tell) a property indicating <code>EXTENDEDVERBS</code> or if any modifier keys are pressed.</p>
  
  <p>Here's the code I'm using now inside the "<code>Opening</code>" event:</p>
  
  <pre><code>// SHIFT KEY is being held down
  if (Convert.ToBoolean(GetKeyState(0x10) &amp; 0x1000))
  {
       _menuStrip.Items.Add(new ToolStripSeparator());
  
       ToolStripMenuItem log = new ToolStripMenuItem("Enable Debug Logging");
       log.Click += new EventHandler(log_Click);
       log.Checked = Settings.Setting.EnableDebugLogging;
       _menuStrip.Items.Add(log);
   }
  </code></pre>
  
  <p>If GetKeyState is the right way of doing it, is my code properly detecting the SHIFT key being pressed?</p>