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

# TCustomTreeView.KeyDown

Handles key down events for the control.

## Declaration

Source position: comctrls.pp line 3622

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

## Arguments

`Key` |  | Virtual key code examined in the method.
`Shift` |  | Shift, Ctrl, Alt modifier for the key code.

## Description

KeyDown is an overridden method in TCustomTreeView which handles key down events for the control.

Key contains the virtual key code examined in the method.

Shift is the Shift, Alt, Ctrl modifier for the key code.

KeyDown calls the inherited method on entry. KeyDown ensures that the following Key codes are handled in the method:

VK_DOWN
  Moves to the next node in the tree. Shift+Down includes the next node in the Selections property.
VK_UP
  Moves to the previous node in the tree. Shift+Up includes the next node in the Selections property.
VK_HOME
  Moves to the tree node at the top of the visible area. Shift+Home includes an affected range of nodes in the Selections property.
VK_END
  Moves to the tree node at the bottom of the visible area. Shift+End includes an affected range of nodes in the Selections property.
VK_PRIOR (PageUp)
  Moves the first node on the previous page for the control. Shift+PageUp includes an affected range of nodes in the Selections property.
VK_NEXT (PageDn)
  Moves the first node on the next page for the control. Shift+PageDn includes an affected range of nodes in the Selections property.
VK_LEFT
  Collapses the current node (when expanded) and moves to the parent node.
VK_RIGHT
  Expands the current node (when needed), or moves to the next expanded node in the tree.
VK_ADD (NumPad Plus)
  Expands the current node. Shift includes the node in a multi-selection range when enabled in Options.
VK_SUBTRACT (NumPad Minus)
  Collapses the current node. Shift removes the node from a multi-selection range when enabled in Options.
VK_F2
  Calls BeginEditing for the Selected node if the control is not ReadOnly.

If the key event is handled in the method, Key is set to VK_UNKNOWN.

## See also

TWinControl.KeyDown |  | Signals OnKeyDown event handlers (when assigned).