Jump to content

How to calculate keyhold time (in milliseconds) of a keypress & inter-key latency time between 2 keys


sasha_eddy

Recommended Posts

Hi, I'm newbie & just have self-learning a few weeks ago...I've tried to understand how to implement my idea into asp.net vb programming & javascript. I've done all parts except the keystroke part.I would like to calculate the keyhold time of a keypress in ms & also the inter-key latency time between 2 keys. The idea is as below:key 'A' is pressed (keydown) - record keyhold timekey 'A' is depressed (keyup) - record keyhold timekey 'A' is pressed & key 'B' is depressed - record inter-key latency time And also, I need ideas how to put my keystroke data into database. Should I record the key character also??Example: A.down.time || A.up.time || A.B.timeWhat do you think is the simplest way to do as I'm a beginner... Tq. . . v(^_^)//

Link to comment
Share on other sites

I would use an array to store timestamps when each key is pressed, and maybe another array to act as a buffer to list the order in which keys were pressed. If you want to go down the buffer then you can get each key, look it up in the other array to get the timestamp, and subtract to get the time between them. You can clear the buffer periodically if you want to, like if no keys are pressed. I'm not sure what you're actually trying to accomplish with this, maybe you clear the buffer or maybe you don't. The array storing timestamps could itself have arrays with multiple timestamps if you want to record multiple presses of the same key versus only the last press. I can't really suggest a database structure, I'm not sure what you're trying to accomplish by recording key strokes and timing.

  • Like 1
Link to comment
Share on other sites

Thank you sir,I have this idea to apply keystroke dynamics authentication by using text password. I would like to write a program that can capture my keystroke style and save it in database, timing is involved because people might press the keyboard keys differently while typing their password. So, I can compare my keystroke style with other users to see if they can impose me even they know my password.... :Pleased:

Link to comment
Share on other sites

I think that idea is way out there. Nobody uses the exact same timing for their keystrokes every time they type their password because milliseconds are a very short measurement of time. Using a form of artificial intelligence you could possibly discover if a typing technique is similar, but that requires advanced knowledge. Then there's the accessibility issue of people trying to log in using browsers that have disabled Javascript and, of course, the fact that the password is saved unencrypted.

Link to comment
Share on other sites

in order to get around the encryption issue it would probably be best to save the password in a normal encrypted safe way, and save the additional timing information but not the actual keys that were pressed. You can save the offsets between keypresses without saving the actual keys. So when they type in a password then you would do the normal check against the encrypted version to first make sure they typed the correct password, and then you can additionally check the timing information if you want to do that also. This system is obviously going to limit which devices you can use though, you wouldn't have the same timing on a laptop or desktop versus a phone or tablet, for example, and it wouldn't work at all for saved passwords. So anyway, if you want to save the timing then I would just get the offsets between each key press, save all of those offsets into a single array, and then I would store the array in a serialized format in the database. You won't be doing database queries for individual timing entries, so there's no problem with saving a serialized array. To check the timing you would get the serialized array, unserialize it back to a normal array, and then loop through it and check each offset against some level of accuracy.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...