Forms > Forms Assembly Interfaces > IControl > IControl.OnKeyPress
OnKeyPress(Sender: Object; Args: IKeyPressEventArgs);
Sender. The parameter that returns the component that has generated the event.
Args. The parameter that enables the user to determine event parameters.
The OnKeyPress event occurs when a component is focused and when the user presses a character key.
When working in the Frame component, the OnKeyPress event occurs after pressing the ENTER, SPACE or ESC keys if the displayed form is hidden (Visible = False). To recognize the auxiliary keys pressing, use the OnKeyDown and OnKeyUp events.
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 OnKeyPress event for all components:
Sub OnKeyPress(Sender: Object; Args: IKeyPressEventArgs);
Begin
If Args.Key = 'A' Then
Args.Key := 'a';
End If;
End Sub OnKeyPress;
After executing the example, if the A Latin capital letter was pressed on entering the text in the area of any component, this letter is replaced with the a Latin lowercase letter in the text.
See also: