OnKeyPress

Syntax

Sub OnKeyPress(Sender: Object; Args: IKeyPressEventArgs);

Begin

//set of operators;

End Sub OnKeyPress;

Parameters

Sender. Parameter that returns the component that has generated the event.

Args. Parameter that enables the user to determine event parameters.

Description

The OnKeyPress event occurs when a component is focused and when the user presses a character key.

Comments

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). The OnKeyDown and OnKeyUp events should be used to recognize the auxiliary keys pressing.

Example

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 "A" Latin capital letter was pressed in the area of any component, when the text was input, this letter is changed for "a" Latin lowercase letter in the text.

See also:

IControl