|
-
Oct 29th, 2010, 01:38 AM
#1
Thread Starter
Junior Member
Keystroke dynamics - keypress calculations
Hi
i want to calculate the delay and the duration of a keypress can
somebody help me with the code?
thank you in advance!
Last edited by jkost; Oct 29th, 2010 at 11:44 AM.
-
Oct 29th, 2010, 01:51 AM
#2
Re: Keystroke dynamics - keypress calculations
If I'm understanding you correctly, you want the KeyboardDelay and KeyboardSpeed properties of the SystemInformation class, assuming WinForms. If that's not what you want then you'll need to provide a clearer explanation.
-
Oct 29th, 2010, 11:48 AM
#3
Thread Starter
Junior Member
Re: Keystroke dynamics - keypress calculations
hi jmcilhinney
i want to calculate how much time in milliseconds a key from the
keyboard is pressed and the time between two keystrokes.
thank you
-
Oct 29th, 2010, 06:07 PM
#4
Thread Starter
Junior Member
Re: Keystroke dynamics - keypress calculations
-
Oct 29th, 2010, 08:00 PM
#5
Re: Keystroke dynamics - keypress calculations
In that case, you can handle the KeyDown and KeyUp events. The time between a KeyDown and a KeyUp is the amount of time a key was depressed and the time between a KeyUp and a KeyDown is the amount of time between presses. You might use a Stopwatch, or you could just record the current time and subtract each time. Both events will tell you which key was involved. If you want to record separately for each key then you could use a Dictionary to record separate values for each key.
By the way, please don't bump your threads. If you don't have any new information to add or a new question to ask then don't post. Posts like "any help?" don;t achieve anything but moving your thread back to the top of the list, which is against forum rules.
-
Oct 29th, 2010, 11:34 PM
#6
Thread Starter
Junior Member
Re: Keystroke dynamics - keypress calculations
following some of jmcilhinney's advices.. i did this:
Code:
Public Class Form1
Dim StopWatchInstance As New System.Diagnostics.Stopwatch()
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
StopWatchInstance.Start()
End Sub
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
StopWatchInstance.Stop()
Console.WriteLine(StopWatchInstance.Elapsed)
End Sub
End Class
i know my code is a bit of nonsense, but that's how far i could go
with almost zero experience on VB net.
can somebody help me put things in an order?
-
Oct 30th, 2010, 12:39 AM
#7
Re: Keystroke dynamics - keypress calculations
What exactly is the problem? You're starting the Stopwatch when the key goes down and stopping it when the key goes up. That will measure time the key is depressed, and you're then displaying that time in the Output window. So, that's what you've got. What does it not do that you want it to do? What does it do that you don't want it to? It's your app so these are things that you must know, so you need to explain it to us.
-
Oct 30th, 2010, 03:47 AM
#8
Thread Starter
Junior Member
Re: Keystroke dynamics - keypress calculations
 Originally Posted by jmcilhinney
What exactly is the problem? You're starting the Stopwatch when the key goes down and stopping it when the key goes up. That will measure time the key is depressed, and you're then displaying that time in the Output window. So, that's what you've got. What does it not do that you want it to do? What does it do that you don't want it to? It's your app so these are things that you must know, so you need to explain it to us.
there must be something wrong with my code because it does nothing
when i press "start debugging" only a window pops up with the text box..
i guess i forgot to do something?..
-
Oct 30th, 2010, 04:14 AM
#9
Re: Keystroke dynamics - keypress calculations
Let's look at my previous post:
What does it not do that you want it to do? What does it do that you don't want it to? It's your app so these are things that you must know, so you need to explain it to us.
Now let's look at your previous post:
it does nothing
when i press "start debugging" only a window pops up with the text box.
Does that address what I posted? No, it doesn't. Please READ what's posted and if questions are asked, please ANSWER them.
So, what exactly do you expect to happen? Firstly, you're handling the KeyDown and KeyUp events of TextBox1, so you will have to set focus to TextBox1 and press some keys. Secondly, you're sending the elapsed time to standard output, so to see it you must watch wherever standard output is being sent. Like I said, that should be the Output window. It is for me at least, although I have a feeling it can be the Intermediate window in some configurations.
Again, please make the effort to provide a FULL and CLEAR description of what you're trying to do, what you're actually doing and what happens. Just saying "it doesn't work" doesn't cut it. Imagine if someone took a car to a mechanic and said "it doesn't work" and the mechanic spent hours trying to find a problem, only to discover that the person wasn't turning the ignition key. You need to provide us with ALL the relevant information. Exactly what you expect to happen and exactly was does happen are always relevant.
-
Oct 30th, 2010, 04:43 AM
#10
Thread Starter
Junior Member
Re: Keystroke dynamics - keypress calculations
 Originally Posted by jmcilhinney
Again, please make the effort to provide a FULL and CLEAR description of what you're trying to do, what you're actually doing and what happens.
there is a form with a text box in the middle, by double clicking with the mouse the text box
you can see the code i posted.
running the code the form appears and i can type in the text box
but other than that nothing else happens.
what i'm expecting to happen is to type a character and then see how
much time in milliseconds has passed since keydown/keyup.
if i manage to do that then what i want to do next is to figure out how am i going to make it
calculate the time in millisecond for words... (delay between keystrokes and duration of a keystroke)
-
Oct 30th, 2010, 07:01 AM
#11
Re: Keystroke dynamics - keypress calculations
 Originally Posted by jkost
what i'm expecting to happen is to type a character and then see how
much time in milliseconds has passed since keydown/keyup.
And where are you expecting to see that time?
-
Oct 30th, 2010, 11:18 AM
#12
Thread Starter
Junior Member
Re: Keystroke dynamics - keypress calculations
i don't know how to complete the "Console.write" command
it is supposed i'm sending data to the output stream...
as i said i'm not an expert
-
Oct 30th, 2010, 06:27 PM
#13
Re: Keystroke dynamics - keypress calculations
Your level of expertise is irrelevant. I'm asking you what you expect. Where do you want to see the elapsed time? If you don't know you want then how can you possibly achieve it? If you don;t know what you want then how can you say that your code isn't working, because you don't know what it's supposed to do in the first place?
This is getting rather frustrating. Please stop and think. What do you want your application to do? How do you want the application to display the elapsed time. Only if you know what it's supposed to do can you make it do it. Only If we know what you want it to do can we help you make it do it. What exactly do you want your app to do? Please don't say that you want it to display the elapsed time because it's already doing that. How, where and in what manner do you want it to display the elapsed time?
-
Oct 30th, 2010, 06:47 PM
#14
Thread Starter
Junior Member
Re: Keystroke dynamics - keypress calculations
ok so! what i did is the following... 
Code:
MsgBox("Time elapsed: " + StopWatchInstance.Elapsed.ToString)
StopWatchInstance.Reset()
now i can see the output of the timer to the msgbox while hours
ago i didn't knew how to use the "StopWatchInstance.Elapsed" and
i was always getting error messages.
i also added the "StopWatchInstance.Reset()" because without it
keeps counting.
so far so good!!!!
how am i going to proceed? since what i care to do is to count the
delay and duration of words and not just letters.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|