title: PyAutoGui - Press key for X seconds
body: <p>I'm currently working on a script that presses the '<strong>w,a,s,d</strong>' keys in order to move a character in any game.
  For this to work, i need to have the '<strong>w</strong>' key pressed for a specific amount of time. How can I achieve this?</p>
  
  <p>I thought of something like:</p>
  
  <pre><code>pyautogui.keyDown('w')
  time.sleep(2)
  pyautogui.keyUp('w')
  </code></pre>
  
  <p>But this just pauses the whole program and no key is being pressed so this has no use to me.</p>