title: Determine whether a virtual-key code belongs to a extended key or a modifier key in .NET
body: <h2>SCENARIO</h2>
  
  <p>I wrote a simple method that acts as a wrapper of <strong><a href="https://docs.microsoft.com/en-us/previous-versions/ms910658(v=msdn.10)" rel="nofollow noreferrer">PostMessage</a></strong> function to send keystrokes to a non-active window. This method takes a <a href="https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes" rel="nofollow noreferrer">virtual-key code</a> as one of its parameters.</p>
  
  <h2>PROBLEM</h2>
  
  <p>Theorycally, modifier keys and extended keys can't be sent through this function (as commented by many professional programmers, for example <strong><a href="https://stackoverflow.com/questions/5144877/sending-ctrl-s-message-to-a-window/5145435#5145435">this comment</a></strong> by @Hans Passant), so, I would like to programmatically determine whether the virtual-key code argument that my method receives it belongs to a "normal" key, a modifier key or a extended key, this way I would be able to treat these last two key types with <a href="https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-keybd_event" rel="nofollow noreferrer">keybd_event</a> or <a href="https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-sendinput" rel="nofollow noreferrer">SendInput</a> function instead of <strong>PostMessage</strong>.</p>
  
  <h2>QUESTION</h2>
  
  <p>How can achieve this in C# or VB.NET?. I always could write a small <strong><em>if</em></strong> or <strong><em>switch</em></strong> to detect the modifier keys because they are only few, but I can't find any Win32 function that can tell me whether a virtual-key code is a extended key or isn't. </p>
  
  <p>To be honest, I don't know exactly what "extended" key stands for, the only information I found about this terminology is on <a href="https://docs.microsoft.com/en-us/windows/desktop/inputdev/wm-keydown" rel="nofollow noreferrer">WM_KEYDOWN</a> / <a href="https://docs.microsoft.com/en-us/windows/desktop/inputdev/wm-keyup" rel="nofollow noreferrer">WM_KEYUP</a> docs, where it says something very superficially:</p>
  
  <blockquote>
    <p>an extended key, such as the right-hand ALT and CTRL keys that appear
    on an enhanced 101- or 102-key keyboard.</p>
  </blockquote>