title: C++ SendInput not letting go off the key
body: <p>I use these codes below, they keep holding both the left and right keys and never let go off them until I press those keys myself.</p>
  
  <p>I could run the left key code and keep pressing the right key.. and it will keep pressing the left key.. only until I press the left key myself will it stop.<br></p>
  
  <p>Same thing happens for the right key when I run the right key code it keeps pressing right I could press left key and it will still keep pressing right key until I press right key myself.</p>
  
  <p>Reason why I used SendInput is because keybd_event is unreliable.. if you don't put a Sleep(Milliseconds) in between DOWN/UP it won't even do anything, and using a Sleep() will throw of the intent of this program it has to tap it as fast as possible, holding the key for any amount of time could result in the wrong answer (this is like a aiming program)</p>
  
  <p>This one is for tapping the Right Key</p>
  
  <pre><code>INPUT ip[1];
  ip[0].type = INPUT_KEYBOARD;
  ip[0].ki.wScan = 0;
  ip[0].ki.time = 0;
  ip[0].ki.dwExtraInfo = 0;
  ip[0].ki.wVk = VK_RIGHT; 
  ip[0].ki.dwFlags = 0;
  
  ip[1].type = INPUT_KEYBOARD;
  ip[1].ki.wScan = 0;
  ip[1].ki.time = 0;
  ip[1].ki.dwExtraInfo = 0;
  ip[1].ki.wVk = VK_RIGHT; 
  ip[1].ki.dwFlags = KEYEVENTF_KEYUP;
  
  SendInput(2, ip, sizeof(INPUT));
  </code></pre>
  
  <p>This one is for tapping the Left Key</p>
  
  <pre><code>INPUT ip[1];
  ip[0].type = INPUT_KEYBOARD;
  ip[0].ki.wScan = 0;
  ip[0].ki.time = 0;
  ip[0].ki.dwExtraInfo = 0;
  ip[0].ki.wVk = VK_LEFT; 
  ip[0].ki.dwFlags = 0;
  
  ip[1].type = INPUT_KEYBOARD;
  ip[1].ki.wScan = 0;
  ip[1].ki.time = 0;
  ip[1].ki.dwExtraInfo = 0;
  ip[1].ki.wVk = VK_LEFT; 
  ip[1].ki.dwFlags = KEYEVENTF_KEYUP;
  
  SendInput(2, ip, sizeof(INPUT));
  </code></pre>
  
  <p>Edit: New code looks like this, err don't like this style.</p>
  
  <pre><code>INPUT ip[1] = {0};
  ip[0].type = ip[1].type = INPUT_KEYBOARD;
  ip[0].ki.wScan = ip[1].ki.wScan = 0;
  ip[0].ki.time = ip[1].ki.time = 0;
  ip[0].ki.dwExtraInfo = ip[1].ki.dwExtraInfo = 0;
  ip[0].ki.wVk = ip[1].ki.wVk = VK_LEFT; 
  ip[0].ki.dwFlags = 0;
  ip[1].ki.dwFlags = KEYEVENTF_KEYUP;
  
  SendInput(2, ip, sizeof(INPUT));
  </code></pre>
  
  <p>Edit again: (also doesn't work) I attempted to trick it into sending KEYUP first.</p>
  
  <pre><code>int intRetValue = -1;
  INPUT ip[2] = {0};
  
  ip[0].type = INPUT_KEYBOARD;
  ip[0].ki.wScan = 0;
  ip[0].ki.time = 0;
  ip[0].ki.dwExtraInfo = GetMessageExtraInfo();
  ip[0].ki.wVk = VK_RIGHT; 
  ip[0].ki.dwFlags = KEYEVENTF_KEYUP;
  ZeroMemory(&amp;ip[1], sizeof(INPUT));
  ip[1].type = INPUT_KEYBOARD;
  ip[1].ki.wScan = 0;
  ip[1].ki.time = 0;
  ip[1].ki.dwExtraInfo = GetMessageExtraInfo();
  ip[1].ki.wVk = VK_RIGHT; 
  ip[1].ki.dwFlags = 0;
  ZeroMemory(&amp;ip[2], sizeof(INPUT));
  ip[2].type = INPUT_KEYBOARD;
  ip[2].ki.wScan = 0;
  ip[2].ki.time = 0;
  ip[2].ki.dwExtraInfo = GetMessageExtraInfo();
  ip[2].ki.wVk = VK_RIGHT; 
  ip[2].ki.dwFlags = KEYEVENTF_KEYUP;
  
  intRetValue = SendInput(3, ip, sizeof(INPUT));
  printf("retValue = %d\n", intRetValue);
  </code></pre>