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

# TKeyEvent

Defines an event handler for key events.

## Declaration

Source position: controls.pp line 465

`type TKeyEvent = procedure(`
`Sender: TObject;`
`var Key: Word;`
`Shift: TShiftState`
`) of object;`

## Arguments

`Sender` |  | TObject for the key event.
`Key` |  | ScanCode for the key in the event.
`Shift` |  | TShiftState modifier for the specified key.

## Description

TKeyEvent is an object procedure type which specifies a handler for key events.

TKeyEvent is the type used to implement the OnKeyDown and OnKeyUp event handlers in TWinControl. Applications must implement an object procedure using the signature for the event, and assign it to the event handler to respond to the notification.

See TKeyPressEvent for the handler used to implement OnKeyPress events.