title: JavaScript key press buffer issue
body: <p>I have a function which starts to gobble up keys after a hot key is pressed and fires off an AJAX process at the end of a sequence (barcode scan).</p>
  <p>The issue is what happens if the user accidentally presses the hot key?</p>
  <p>My paper napkin solution was:</p>
  <pre><code>on hotkey: if(okay(true)) {buffer=&quot;&quot;; ts=now(); consumekey();}
  on EOTkey: if(okay(false)) {AJAX(buffer); consumekey();}
  on datakey: if(okay(false)) {appendbuffer(key); consumekey();}
  on otherkey: dumpbuffer();    
  
  var status=false;
  var ts=0;
  var buffer=&quot;&quot;;
  
  function okay(bool state)
  {
   if (state &amp;&amp; !status) || (!state &amp;&amp; status &amp;&amp; !timeout(ts) ) return true;
   dumpbuffer();
  }
  
  function dumpbuffer()
  {
   mybuffer=buffer;
   buffer=&quot;&quot;;
   ts=0;
   status=false;
   sendkeys(mybuffer);
  }
  </code></pre>
  <p>So how do we write <code>sendkeys</code> in JavaScript? (BTW this can be IE specific). The current implementation uses jQuery, but our code does not have any content for the <code>sendkeys</code> function.</p>