Skip to content

Instantly share code, notes, and snippets.

@tatocaster
Last active April 22, 2016 12:34
Show Gist options
  • Save tatocaster/9250070 to your computer and use it in GitHub Desktop.
Save tatocaster/9250070 to your computer and use it in GitHub Desktop.
javascript, detect seconds between keypress
milliseconds = 0;
timeHandle = null;
window.onkeypress = function(){
clearInterval(timeHandle);
if (milliseconds > 0){
console.log('passed ' + milliseconds*10 + ' milliseconds');
milliseconds = 0;
}
timeHandle = setInterval(function(){
milliseconds++;
},10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment