KeyEvent
From Xojo Documentation
Module
An intrinsic object that contains constants used to test which key was released.
Constants
Here are the constants that identify which key was released in a KeyPressed event.
Class Constant |
---|
KeyAlt |
KeyArrowLeft |
KeyArrowRight |
KeyArrowUp |
KeyArrowDown |
KeyBackspace |
KeyCapsLock |
KeyCommand |
KeyCommandRight |
KeyControl |
KeyDelete |
KeyEnd |
KeyEnter |
KeyEscape |
KeyF1 |
KeyF2 |
KeyF3 |
KeyF4 |
KeyF5 |
KeyF6 |
KeyF7 |
KeyF8 |
KeyF9 |
KeyF10 |
KeyF11 |
KeyF12 |
KeyF13 |
KeyF14 |
KeyF15 |
KeyF16 |
KeyF17 |
KeyF18 |
KeyF19 |
KeyHome |
KeyMenu |
KeyMeta |
KeyNumlock |
KeyPageDown |
KeyPagUp |
KeyPause |
KeyPrintScreen |
KeyScrollLock |
KeyShift |
KeySpace |
KeyTab |
KeyWindows |
KeyWindowsRight |
Examples
You can determine which key was released in the KeyPressed event of a Web application. This event is passed a parameter, Details as Realbasic.KeyEvent, that holds this key. Test it by checking it against a list of constants. For example, the following Select statement determines which arrow key was pressed.
Select Case details.KeyCode
Case details.KeyArrowDown
MsgBox("Down arrow")
Case details.KeyArrowLeft
MsgBox("Left arrow")
Case details.KeyArrowRight
MsgBox("Right arrow")
Case details.KeyArrowUp
MsgBox("Up arrow")
End Select
Case details.KeyArrowDown
MsgBox("Down arrow")
Case details.KeyArrowLeft
MsgBox("Left arrow")
Case details.KeyArrowRight
MsgBox("Right arrow")
Case details.KeyArrowUp
MsgBox("Up arrow")
End Select
Note that some keys are hijacked by the OS and will not trigger an event (like some function keys on macOS and Windows).