Command: IsKeyPressed
- Updated2024-09-12
- 2 minute(s) read
Command: IsKeyPressed
Command: IsKeyPressed
Specifies whether the specified key was pressed.
Input Parameters
![]() |
Specifies the pressed key. |
Return Parameters
ReturnValue | The return value is a Boolean variable type. |
Use the IsKeyPressed command to request the keys of the keyboard and of the mouse. The command returns the physical key not the logical key. For example, even if a left-handed user re-configured the mouse buttons, the command returns the left mouse button when this button is pressed.
Example
The following example outputs a message after the space bar was pressed. The KeyWait stops the script until a key is pressed.
VBScript | Python |
Call MsgBoxDisp("Press space bar.",,,,5,True) Do While Not IsKeyPressed(&H20) Call KeyWait Loop Call MsgBoxDisp("Space bar pressed")