Here is "ONE" way.. it detects the Enter press in .NET Win Forms. The 13 represents "Enter".
Public Function KeyAscii(ByVal UserKeyArgument As KeyPressEventArgs) As Short
KeyAscii = Asc(UserKeyArgument.KeyChar)
End Function
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If KeyAscii(e) = 13 Then
MsgBox("you press ENTER key")
End If
End Sub
More key types can be found by using something like this to detect your key presses.
Private Sub Form_KeyPress(KeyAscii As Integer)
Debug.Print "KeyAscii: " & KeyAscii
End Sub
Private Sub Form_Load()
Form1.KeyPreview = True
End Sub