KeyDown Event
This event occurs when one or more keys are pressed while the control is in focus. For more information, see Sample Automation.
Note: There are related KeyUp and KeyPress events. The events fire in the following order:
KeyDown event occurs first when a key is pressed
KeyPress event fires
KeyUp event fires when the key is released
This event has the following arguments. To access the arguments, click the double-down arrow at the top of the connection block.
Event Arguments |
Description |
Sender |
The name of the control initiating the event. Here is an example: rtbNotes [OpenSpan.Adapters.Controls.RichTextBox] |
Alt |
Gets a value of True when the Alt key is pressed in the control. |
Control |
Gets a value of True when the Ctrl key is pressed in the control. |
Handled |
Gets or sets a Boolean value that indicates whether the control's default handling is bypassed. When set to True, the default control handling is not used. Note that the effect of bypassing the default control handling differs depending on the control. See the MSDN KeyEventArgs topic for more information. |
KeyCode |
Gets the keyboard code corresponding to the key pressed. For example, pressing Shift A to enter an upper case A, the KeyCodes are "Shift” then "A". See the MSDN Keys Enumeration topic for a list of Key Codes. |
KeyData |
Gets the key command corresponding to the key pressed. The key command includes the modifier (Shift, Ctrl, and so on) and the key code. For example, pressing Shift+A to enter an uppercase A, the KeyData is "Shift+ShiftKey” for the Shift key then "Shift+A" when the A is pressed. See the MSDN Keys Enumeration topic for a list of key codes. |
KeyValue |
Gets the integer value corresponding to the KeyCode for the key pressed. For example, pressing Shift+A to enter an uppercase A, the KeyValue is "16" for the Shift key and then "65" for the A key. See the MSDN KeyEventArgs.KeyValue Property topic for more information. |
Modifiers |
Gets the combination of modifier keys (Ctrl, Shift, and Alt) that have been pressed. For example, if the Ctrl+Alt keys are pressed, the result output is Ctrl+Alt+None |
Shift |
Gets True when the Shift key is pressed in the Control. |
SuppressKeyPress |
Gets or sets a boolean value. When set to True, the KeyDown event is suppressed and the output value is True. In this case, the control will not receive the KeyPress event. When set to False (the default), the event is not suppressed and the output value is False. |
The following automation shows how the KeyDown method can be used. In this automation, the KeyDown method is used to launch specific actions depending on which key has been pressed.
Keys Pressed |
KeyCode |
KeyData |
KeyValue |
Description |
F1 |
F1 |
F1 |
112 |
Displays a message dialog showing help regarding the control |
PageDown |
PgDn |
PgDn |
34 |
Closes the active New Call Window and opens a another New Call window. |
Esc |
Escape |
Escape |
27 |
Closes the CRM application. |
The KeyCode, KeyValue and KeyData arguments are used in the first automation. The second automation shows using only the KeyValue argument.
This event fires when a key is released while the Control has focus. The parameters for this event are the same as the KeyDown event. The only difference is that the values are output after the key is released.
Privacy | Trademarks | Terms of Use | Feedback
Updated: 01 July 2024
© 2016 - 2024 Pegasystems Inc. Cambridge, MA All rights reserved.