SendKeyObject
- Last UpdatedOct 29, 2026
- 3 minute read
The function SendKeyObject sends a key event code to objects in the currently displayed project screen. You can use this function to trigger Command animations on those objects.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
SendKeyObject |
Module Activity |
Synchronous |
No |
Supported |
Supported |
Not supported |
Supported |
Not supported |
Syntax
SendKeyObject(numEvent,strMainKey,numShift,numCtrl,numAlt,strTargetScreen,optNumID)
SendKeyObject ( { numEvent | 0 | 1 | 2 } ,strMainKey { | , { numShift | 0 | 1 } , { numCtrl | 0 | 1 } , { numAlt | 0 | 1 } ,strTargetScreen { | ,optNumID } } )
numEvent
A numeric value that indicates the type of key event to send to the screen. The following values are accepted:
|
Value |
Description |
|---|---|
|
0 |
On Down |
|
1 |
On While |
|
2 |
On Up |
For more information about these key events, see Command animation.
Note: If the "On While" event is specified, the "On While" script on the Command animation is executed just once for each time this function is executed. It is not continuously executed as if the key is pressed and held down, because this function does not have a parameter for specifying duration. If you want to cause that sort of behavior, you can include this function in an appropriately configured FOR loop.
strMainKey
The key to be sent to the screen. The following values are accepted:
|
Value |
Description |
|---|---|
|
"A" … "Z" |
alphabetic characters A through Z |
|
"+" |
plus symbol |
|
"-" |
minus symbol |
|
"*" |
multiply symbol |
|
"/" |
divide symbol |
|
"LEFT" |
left arrow (←) |
|
"UP" |
up arrow (↑) |
|
"RIGHT" |
right arrow (→) |
|
"DOWN" |
down arrow (↓) |
|
"HOME" |
Home key |
|
"END" |
End key |
|
"PAGEUP" |
Page Up key |
|
"PAGEDOWN" |
Page Down key |
|
"INSERT" |
Insert key |
|
"DELETE" |
Delete key |
|
"SPACE" |
Space key |
|
"RETURN" |
Return key |
|
"BACKSPACE" |
Backspace key (if different from Delete key) |
|
"ESCAPE" |
Escape key |
|
"F1" … "F20" |
function keys F1 through F20 |
The key must be enclosed in quotes, as shown.
numShift
A numeric value that indicates whether to include Shift with the specified key (for example, Shift+R). The following values are accepted: 0 is no, 1 is yes.
This parameter is optional; if no value is specified, the default value is 0.
numCtrl
A numeric value that indicates whether to include Ctrl with the specified key (for example, Ctrl+R). The following values are accepted: 0 is no, 1 is yes.
This parameter is optional; if no value is specified, the default value is 0.
numAlt
A numeric value that indicates whether to include Alt with the specified key (for example, Alt+R). The following values are accepted: 0 is no, 1 is yes.
This parameter is optional; if no value is specified, the default value is 0.
strTargetScreen
The name of the screen that will receive the key event code.
This parameter is optional; if no value is specified, the currently active screen is used.
optNumID
The specific ID number of the screen. (The ID number is assigned when the screen is opened with the function Open.)
This parameter is optional; if no value is specified, the default value is 0.
Return value
This function returns no value.
Notes
If the Enforce Web functionality equivalence in local project screens option is selected in the project settings, this function cannot be called in VBScript Global Procedures, VBScript scripts (script groups), or other background tasks. This is because the function behaves differently depending on whether you view project screens locally (that is, on the same computer that hosts the project runtime) or remotely. For more information, see Preferences tab.
Also, the parameters numShift, numCtrl, numAlt and strTargetScreen are all optional, but if you configure one of them, you must configure the others as well.
Examples
Send R to the currently active screen:
SendKeyObject(0,"R")
Send Ctrl+Shift+R to the screen named "main" with ID 10:
SendKeyObject(0,"R",1,1,0,"main",10)