title: Define an action when clicking at a specified time in JS
body: <p>Here is the problem, I created a time management in JavaScript to allow to say that when I click on a key at a specific time I have such action that occurs. For that I created a chrono function that repeats in loop and increments 100ms with each repetition, until then everything is well. I put my code in this function to be able to enjoy the time management, I then say that if my time that is greater than so much second and if I click the "a" key on my keyboard adds 1 to score. And that's when it does not work, instead of having 1 point the number of times I clicked on "a", I have the number of repetitions of the loop and if I reclick It will repeat the name and add it etc ...</p>
  
  <p>I really see by whom is the concern, unless I try to do something that is not possible in JS or unless the problem is in jQuery. Anyway thanks to those who help solve the problem. Excuse me for the faults I'm french ^^</p>
  
  <hr>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  var sec = 0,
    score = 0;
  
    function chrono(){
  
        sec++; 
        $("p#chrono_crashtest").html(sec);
  
        $("#point_go").html(score);
  
        if(sec &gt; 5){
            $(document).keyup(function(le_click){
  
                if(le_click.keyCode == 65){
                        score++;
                }
  
            });
        }
  
  
    setTimeout("chrono()",100); 
    }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
   &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
  
   &lt;!-- html --&gt;
      &lt;p&gt;chrono&lt;/p&gt;&lt;p id="chrono_crashtest"&gt;0&lt;/p&gt;
      &lt;input type="button" value="go chrono" onclick="chrono()" id="btn_chrono_crashtest"&gt;
   &lt;p&gt;score =&lt;/p&gt;&lt;p id="point_go"&gt;0&lt;/p&gt;
  
   &lt;!-- jQuery --&gt;
   &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
   &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>