title: Virtual key code of ALT KEY
body: <p>I am making hooks and catching keyboard virtual key codes, according to MSDN, <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx" rel="nofollow noreferrer"> these are </a>the key codes that exist. </p>
  
  <p>Every key code works fine as i will give an example down below of my code.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;windows.h&gt;
  
  HHOOK altKey;
  KBDLLHOOKSTRUCT kbdHK;
  MSG message;
  
  LRESULT CALLBACK kbdProc(int nCode, WPARAM wPar, LPARAM lPar);
  
  int main(int argc, char *argv[]) {
    altKey = SetWindowsHookEx(WH_KEYBOARD_LL, kbdProc, NULL, 0);
  
    while(GetMessage(&amp;message, NULL, 0, 0) &gt; 0){
      TranslateMessage(&amp;message);
      DispatchMessage(&amp;message);
    }
    return 0;
  }
  
  LRESULT CALLBACK kbdProc(int nCode, WPARAM wPar, LPARAM lPar){
  
    if(nCode &gt;= 0){
      if(wPar == 256){
        kbdHK = *(KBDLLHOOKSTRUCT *)lPar;
        if(kbdHK.vkCode == 0x20){
          printf("spacebar pressed!!\n");
        }
      }
    }
    return CallNextHookEx(NULL, nCode, wPar, lPar);
  }
  </code></pre>
  
  <p>But when I replace the virtual key code with <code>0x12</code> which is ALT KEY according to <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx" rel="nofollow noreferrer">MSDN</a>, I can't get a result back. What could be the problem?</p>
  
  <p><strong>Edit</strong>:</p>
  
  <p>When I use this line of code, I can get the <code>scanCode</code> for every key but not for alt key again which is interesting.</p>
  
  <pre><code>printf("%d", kbd.scanCode); 
  </code></pre>