'in the KeyPress event of any control
If KeyAscii = vbKeyReturn Then
MSGBox "Enter was pressed!"
End If
'this is the same as using character code constants
If KeyAscii = 13 Then
MSGBox "Enter was pressed"
End If
'KeyCode represents the physical key that is pressed/released (all keys except TAB)
'in the KeyUp events
If KeyCode = vbKeyReturn Then
MSGBox "Enter key was released"
End If
'in the KeyDown events
If KeyCode = vbKeyReturn Then
MSGBox "Enter key was pressed"
End If
'other useful KeyCode constants include:
'vbKeyLButton vbKeyRButton
'vbKeyReturn
'vbKeyShift
'vbKeyControl
'vbKeyEscape
'vbKeySpace
'vbKeyUp vbKeyDown vbKeyLeft vbKeyRight
'vbKeyPageUp vbKeyPageDown vbKeyEnd vbKeyHome
'vbKeyF1 - vbKey16