Created
December 5, 2012 11:47
-
-
Save uupaa/4214948 to your computer and use it in GitHub Desktop.
tap/click time logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html><head><meta charset="utf-8"> | |
<script> | |
window.onload = function() { | |
var lastTouchEnd = 0; // last touchend time | |
document.body.addEventListener("mousedown", touchstart, false); | |
document.body.addEventListener("mouseup", touchend, false); | |
document.body.addEventListener("touchstart", touchstart, false); | |
document.body.addEventListener("touchend", touchend, false); | |
function touchstart(event) { | |
var diff = Date.now() - lastTouchEnd; | |
if (diff <= 16) { // 16ms | |
alert("I guess you are right: " + diff + " ms"); | |
} else { | |
console.log(diff); | |
} | |
} | |
function touchend(event) { | |
lastTouchEnd = Date.now(); | |
} | |
}; | |
</script> | |
</head><body> | |
<p>tap/click time logger</p> | |
<p>tap me!</p> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment