You can't use KeyPress as that only handles non-character key's such as Enter.
You'd have to do something similar to the below:
vbnet Code:
Dim keypressed As Boolean Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles TextBox1.KeyDown If keypressed = False Then If e.KeyData = Keys.W Then MsgBox(TimeOfDay & " " & "Cough") keypressed = True End If End If End Sub Private Sub TextBox1_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp If e.KeyData = Keys.W Then keypressed = False End If End Sub




Reply With Quote