javascript - Call function again only after it finish executing -


i have function gets called every time enter key pressed. need make function not called if press enter key again, if , when function has not finish executing yet. when function has finished executing, called again if press enter key again. how in jquery, or javascript?

onkeydown = 'if(event.keycode==13) somefunction()'  function somefunction() {  //some codes //some settimeouts  } 

simply set boolean when done , check before executing function.

onkeydown = 'if(event.keycode==13) { if (!finished){somefunction();}'  var finished = false;  function somefunction() {     finished = false       //some codes     //some settimeouts      finished = true;  }

though, luis points out, javascript single threaded , shouldn't running problems describe unless not understanding problem fully.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -