OnKeyPress

Syntax

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

Begin

//set of operators;

End Sub OnKeyPress;

Parameters

Sender. Parameter that returns the component, generated an event

Args. Parameter that allows to determine the event parameters.

Description

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

Comments

The OnKeyPress event occurs the user presses the ENTER, SPACE or ESC keys. 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