title: How to hold key down with Selenium
body: <p>I am using Selenium with Python and Chrome.  I am trying to hold down various keys -- specifically "w, a, s, and d."  I have found Selenium's action_chains.key_press action as well as the elem.send_keys method.  The problem with the first method is that it only holds the key down for as long as it takes to complete an action chain.  The problem with the elem.send_keys method is that it does not have an element to send the keys to.</p>
  
  <p>I am trying to control a web-browser based robot with W-A-S-D, so I need to hold keys down for varying durations.  </p>
  
  <p>I have tried the following:</p>
  
  <pre><code>action_chains = ActionChains(driver)
  action_chains.key_down("w")
  action_chains.key_up("w")
  </code></pre>
  
  <p>as well as:    </p>
  
  <pre><code>action_chains.key_press(elem, "w")
  for x in range (0, 100):
      action_chains.perform()
      time.sleep(.01)
  </code></pre>
  
  <p>Neither are ideal.</p>