Created
July 22, 2024 06:59
-
-
Save asd142513/967403727f384b7eefef2477396e44a5 to your computer and use it in GitHub Desktop.
Print the time interval since the last press or release
This file contains hidden or 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
<html> | |
<body onmousedown="mouseDown();" onmouseup="mouseUp();"> | |
<textarea id="box" readonly rows="24" cols="80" placeholder="unit: ms(milisecond)"></textarea> | |
</body> | |
<script type="text/javascript"> | |
var box = document.getElementById('box'); | |
var last = Date.now(); | |
function mouseDown() { | |
cur = Date.now(); | |
var s = 'press\t' + (cur - last) + '\n'; | |
box.value = s + box.value; | |
last = cur; | |
} | |
function mouseUp() { | |
cur = Date.now(); | |
var s = 'release\t' + (cur - last) + '\n'; | |
box.value = s + box.value; | |
last = cur; | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment