title: Javascript onkeyup delayed function call
body: <p>I want to make a Javascript function that fires <code>onkeyup</code> event and its task is to call a main resolver function but only if no keys are fired for at least x milliseconds where <code>x</code> is the functions parameter.</p>
  <p>For instance:</p>
  <p>We have html code:</p>
  <pre><code>&lt;body&gt;
      &lt;input type=&quot;text&quot; id=&quot;suggestion&quot; onkeyup=&quot;callMe(200);&quot;/&gt;
  &lt;/body&gt;
  </code></pre>
  <p>and Javascript something like:</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
      function callMe(ms)
      {
          //wait at least x ms then call main logic function
          // e.g. doMain();
          alert(&quot;I've been called after timeout&quot;); //for testing purposes
      }
  &lt;/script&gt;
  </code></pre>
  <p>So while I'm typing the alert won't be called until you don't type anything for at least x ms.</p>