Set a variable to true 2 seconds after the last time "G" has been pressed
<p>Title says it all, I know a pretty stupid way to solve this via Javascript but I wonder... if there is a smarter way? There probably is. A user can press "G" as much as he wants and this calls the function <strong>g_pressed();</strong>. Solutions in jquery are also fine.</p>

<p>Here's my solution:</p>

<pre><code>var allowed = false;
var allowed_key = 0;

function g_pressed(){
    allowed = false;
    allowed_key++;
    setTimeout('allowed_check('+allowed_key+');', 2000);
}

function allowed_check(key){
    if(key==allowed_key){
        allowed = true;
    }
}
</code></pre>

<hr>

<p>As you can see, it is painfully 12 lines long.</p>
