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

# TCustomCheckListBox.KeyDown

Handles key down messages for the control.

## Declaration

Source position: checklst.pas line 70

`protected procedure TCustomCheckListBox.KeyDown(`
`var Key: Word;`
`Shift: TShiftState`
`); override;`

## Arguments

`Key` |  | Keystroke examined in the method.
`Shift` |  | Shift, Control, or Alt modifier for the keystroke.

## Description

KeyDown is an overridden method in TCustomCheckListBox used to handle key down messages for the control. KeyDown ensures that the value for the current check box is toggled when the Space key is pressed while the control has focus.

This includes setting ItemIndex to 0 when it has a value not valid for the Items defined in the control. The inherited Click method is called if ItemIndex is range adjusted. This behavior is Delphi (version 7 at least) compatible.

If the check box at ItemIndex has its ItemEnabled property set to True, the value in Checked is toggled. The ClickCheck and ItemClick methods are called to trigger the corresponding event handlers. The value in Key is set to VK_UNKNOWN when the keystroke has been handled in the method.

The inherited KeyDown method is called to handle other key down events.

## See also

TCustomCheckListBox.Checked |  | Provides indexed access to the Boolean Checked or Unchecked state for Items in the control.
TCustomCheckListBox.ItemEnabled |  | Provides indexed access to the enabled state for Items in the control.
TCustomCheckListBox.ClickCheck |  | Performs actions needed when a value in the control is about to change.
TCustomCheckListBox.ItemClick |  | Deprecated. Performs actions when the specified check box has been changed using the mouse or the keyboard.
TWinControl.KeyDown |  | Signals OnKeyDown event handlers (when assigned).
TCustomListBox.Click |  | Performs the Changed method when the control is clicked.