I wanna calculate the time between key 37 and 39 pressed. This is the left and right key.
So the user would press the two keys and i must calculate between each 2 key presses how long each gap was.
Typical times range from 70 to 150 milliseconds. Key digram durations are measured from the key-down event of one keypress to the key-down event of the following. These can range from 50 to 200 milliseconds.
Most keyboards have a 6 key rollover which means they can correctly register that 6 keys are being pressed simultaneously. Some gaming computers have 10-25 key rollover capability! WOW!
The Windows on-screen keyboard is a program included in Windows that shows an on-screen keyboard to test modifier keys and other special keys. For example, when pressing the Alt , Ctrl , or Shift key, the On-Screen Keyboard highlights the keys as pressed.
Something like:
var start = 0;
$("#input").keyup(function(e) {
if(e.keyCode == 37) {
start = new Date().getTime();
} else if(e.keyCode == 39) {
var elapsed = new Date().getTime() - start;
alert("elapsed time in milliseconds is: " + elapsed);
// start again
start = 0;
}
});
Mess with it here: http://jsfiddle.net/9vmb4/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With