Key Stroke events

blacksaibot

Member
Joined
Mar 22, 2012
Messages
8
Programming Experience
Beginner
I am trying to create a typing tutor program with an animation.


How can I make a sub that tracks the typing in real-time?


I know how to compare strings, but I would like to catch the mistakes as the user is typing them.

So, for example, if the text asks the user to type DOG, and they type "D" there will be a picture of a keyboard with an animation showing them which key they just pressed.


Also, how can I achieve this for multiple active windows? For example, if the user types it inside of notepad or word instead of me having to reinvent the wheel (ie formatting, tabs, etc - I would hate to have to try and program all that). So I can have the animation window set as "always on top" while the user types inside of word.

I hope that makes sense.


Thanks in advance.
 
Here you go.

VB.NET:
Private Sub SplashScreen1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress

call CheckLetter(e.KeyChar)


        Select Case e.KeyChar
            Case Is = ChrW(Keys.F4)
                e.KeyChar = Nothing
                e.Handled = True
            Case Is = ChrW(Keys.Escape)
                e.KeyChar = Nothing
                e.Handled = True
end sub

you could use something like this for getting the key compared
VB.NET:
Dim Word as String
Dim WordLetter as byte = 1

Public Sub CheckLetter()
when the key is pressed pass the better to the checkletter sub, you could put the word in the var word and use wordletter to track what letter they are on in that word.

i havn't tried this code. bbut im sure you will be able to figure out your way of using it

Hope this help
 
Back
Top