title: How to delay KeyPress function when user is typing, so it doesn't fire a request for each keystroke?
body: <p><strong>background</strong></p>
  
  <p>I have a number of dropdowns on a page. If you change the first one, the rest of the dropdowns are updated according to what you've selected.</p>
  
  <p>In our case, we deal with fund data. So the first dropdown is "All Fund Types". You select "Hedge Funds", and the next dropdown is filtered by options that only apply to Hedge Funds.</p>
  
  <p>The client is now asking me to put a text field into the mix, which when the user starts typing, will effect those results.</p>
  
  <p>So if they type "USD", the second dropdown will only contain options that have funds with "USD" in the name.</p>
  
  <p><strong>problem</strong></p>
  
  <p>The specific problem that I'm having is that with the code I'm using:</p>
  
  <pre><code>$('#Search').keypress(function () {
      // trigger the updating process
  });
  </code></pre>
  
  <p>It's triggering the search for each key press. So when I type "USD" I'm getting 3 requests immediately - one for "U", one for "US" and one for "USD".</p>
  
  <p>I've tried setting a timeout with this:</p>
  
  <pre><code>$('#Search').keypress(function () { 
      // I figure 2 seconds is enough to type something meaningful
      setTimeout(getFilteredResultCount(), 2000);
  });
  </code></pre>
  
  <p>but all that does is wait 2 seconds before doing what I've described.</p>
  
  <p>I'm sure this problem has been solved before. Could somebody suggest how to solve this issue? </p>