Sub OnKeyDown(Sender: Object; Args: IKeyEventArgs);
Begin
//set of operators;
End Sub OnKeyDown;
Sender. Parameter that returns the component, generated an event
Args. Parameter that allows to determine the event parameters.
The OnKeyDown event occurs if a component is focused and a keyboard key is pressed.
The event occurs on pressing such auxiliary keys as 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;
The name of this component with Down word is displayed in the form name, if the combination of CTRL+B keys is pressed in the area of any component, after an example execution.
See also: