Cancel: Boolean;
The Cancel property indicates whether the further event that is connected to the keys pressing, should occur. If the property is set to True, the further event is cancelled.
For the example to be executed, a form should exist. Several components that can receive focus are placed on the form. The following procedure is used as a handler of the OnKeyPreview event for all components:
Sub ProcedureOnKeyPreview(Sender: Object; Args: IKeyPreviewEventArgs);
Begin
If Args.Key = Keys.F1 Then
Args.Cancel := True;
End If;
End Sub ProcedureOnKeyPreview;
After executing the example, if the F1 functional key was pressed in the area of any component, when the text was entered, the further events (such as OnKeyDown, OnKeyUp) do not occur.
See also: