Sub OnKeyDown(Sender: Object; Args: IKeyEventArgs);
Begin
//set of operators;
End Sub OnKeyDown;
Sender. Parameter that returns the component that has generated the event.
Args. Parameter that enables the user to determine event parameters.
The OnKeyDown event occurs if the component is focused and a keyboard key is pressed.
The event occurs on pressing the auxiliary keys: SHIFT, ALT, and CTRL.
If it is not necessary to recognize the auxiliary keys pressing, it is reasonable to use the OnKeyPress event.
Executing the example requires a form. Several components that can receive focus are placed on the form. The following procedure is used as a handler of the OnKeyDown event for all components:
Sub OnKeyDown(Sender: Object; Args: IKeyEventArgs);
Begin
If (Args.ShiftState = ShiftState.Ctrl) And (Args.Key = Keys.B) Then
Text := (Sender As IControl).Name;
End If;
End Sub OnKeyDown;
After executing the example the name of this component with Down word is displayed in the form name, if CTRL+B was pressed in the area of this component.
See also: