title: C++ Simulating key presses only once
body: <p>I have tried everything I found in google but nothing works. I want to press <code>A</code> for <strong>5 seconds</strong>, but everything presses it only once.It just releases it immediately. Pressing multiple times is not the answer because the key must be pressed for atleast 30ms.</p>
  
  <pre><code>const int KEYEVENT_KEYUP = 0x02;
  
  keybd_event(0x41, 0, 0, 0);
  Sleep(5000);
  keybd_event(0x41, 0, KEYEVENT_KEYUP, 0);
  </code></pre>