Public Class Form1 Dim kacDefa As Integer = 0 Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown If e.KeyValue = Keys.W Then kacDefa += 1 Label1.Text = "W pressed " & kacDefa & " time(s)" End If End Sub End Class
That's quite true, because KeyDown is about keys on the keyboard while KeyPress is about characters. Not all keys correspond to characters and not all characters are the product of a single key. That said, you can detect specific key combinations using KeyDown, e.g. Shift+W. Socarsky, to learn more about keyboard events, follow the Blog link in my signature and check out my post on the subject.Hi,
You cannot differentiate case sensitivity in the KeyDown event but you can differentiate case sensitivity in the KeyPress event using the e.KeyChar property.
Hope that helps.
Cheers,
Ian
Got the topic in your blog and I started to read it. Here is the link: John McIlhinney's .NET Developer Blog: Keyboard Events in Windows FormsThat's quite true, because KeyDown is about keys on the keyboard while KeyPress is about characters. Not all keys correspond to characters and not all characters are the product of a single key. That said, you can detect specific key combinations using KeyDown, e.g. Shift+W. Socarsky, to learn more about keyboard events, follow the Blog link in my signature and check out my post on the subject.