I am working on a students project where a webscript (javascript) logs keystroke events (keydown and keyup). At a later stage it should be possible to detect the identity of a user based on their keystroke behaviour.
My question: How fast can javascript react to user events like keydown or keyup. Is it in the range of a few miliseconds or even more? I don't know exactly how accurate the measurements should be but I guess it should be in the range of a few milliseconds.
I have done a lot of research but I couldn't get it out. I found out that the user-event latency of an operating system is about 100 to 10 nano seconds but I have no idea how long it takes until the user-event reaches my webscript.
Also I found out that Firefox handles javascript user events faster than other browsers, because it fires the event regardless of what the main javascript UI thread is doing. Is there a possibilty to find it out? Maybe an assembler program which logs my keystrokes and running simultaniously the javascript program and then compare the log times. Is something like this possible?
Here is a small snippet of my code:
document.getElementById("myInputField").onkeydown = function(event) {myFunction(event);};
function myFunction(event) {
keystrokes.push({ 'time': performance.now(),'type':'keyDown','code':event.keyCode});
}
Thank you.