[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Controls' (#lcl)

TWinControl.OnKeyDown

Event handler signalled for key down keyboard events.

Declaration

Source position: controls.pp line 2359

public property TWinControl.OnKeyDown : TKeyEvent
  read FOnKeyDown
  write FOnKeyDown;

Description

OnKeyDown is a TKeyEvent property with the event handler signalled to handle a key down event for the control. The event handler receives keys including control and other non-visual keys. It is signalled (when assigned) from the KeyDown method.

The Sender argument contains the control for the key event. It must be cast to TControl or TwinControl type to access properties or methods specific to the descendent classes.

The Key argument contains the virtual keyboard constant for the key event (like VK_F1 or VK_NUMPAD5). It is a variable argument and can be modified in the event handler. Set Key to VK_UNKNOWN if the handler routine has performed the actions needed to handle the key event. Otherwise, Key is passed to other OnKeyDown handlers at the form or application level.

Shift is a set type which contains the modifiers for the key down event like: Ctrl, Shift, Alt, or Meta.

Remark: When a key is held down, the OnKeyDown event is re-triggered. The first re-triggered event occurs after approximately 500ms, and subsequent events cycle between 30ms and 50ms until the key is released.

Use OnKeyUp to perform actions needed when the key is released.

Use OnKeyPress or OnUTF8KeyPress to implement a handler routine for printable character values.

See also

TWinControl.KeyDown

  

Signals OnKeyDown event handlers (when assigned).

TWinControl.OnKeyUp

  

Event handler signalled when a key up event has occurred for the control.

TWinControl.OnKeyPress

  

Event handler signalled for character data entered by the user.

TKeyEvent

  

Defines an event handler for key events.


Version 3.2 Generated 2024-02-25 Home