ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Keystroke identification (https://www.excelbanter.com/excel-programming/360004-keystroke-identification.html)

Tim[_44_]

Keystroke identification
 
I have a userform and a textbox. Code is as follows:

Option Explicit
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
' MsgBox KeyAscii & Chr(KeyAscii)
End Sub
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
MsgBox KeyCode & Chr(KeyCode) & Shift
End Sub

The help documentation indicates that _KeyPress should be used to
interpret keystrokes, but that _KeyUp or _KeyDown should be used to
identify non-printable keys such as <Page Up or <Insert. How do
people normally interpret keys when you need more definition than ANSI
definition allows? Are the KeyCodes in _KeyUp keyboard specific?



All times are GMT +1. The time now is 01:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com