title: Call function again only after it finish executing
body: <p>I have a function that gets called every time the enter key is pressed. I need to make it so that the function will NOT be called if you press the enter key again, IF and when the function has not finish executing yet. Only when the function has finished executing, will it be called again if you press the enter key again. How would I do this in jQuery, or JavaScript?</p>
  
  <pre><code>onKeyDown = 'if(event.keyCode==13) someFunction()'
  
  function someFunction() {
  
  //some codes
  //some setTimeouts
  
  }
  </code></pre>