Vcl.Controls.TWinControl.KeyPress
Delphi
procedure KeyPress(var Key: Char); dynamic;
C++
DYNAMIC void __fastcall KeyPress(System::WideChar &Key);
Properties
| Type | Visibility | Source | Unit | Parent |
|---|---|---|---|---|
procedure function |
protected | Vcl.Controls.pas Vcl.Controls.hpp |
Vcl.Controls | TWinControl |
Description
Responds to keyboard input.
When a windowed control receives a key-press message (WM_CHAR) from Windows, its message handler calls the DoKeyPress method. If DoKeyPress determines that the control should, in fact, process the character, it calls KeyPress, passing the key code in the Key parameter.
KeyPress calls any event handler attached to the OnKeyPress event. Override KeyPress to provide other responses in addition to the event handler call.
Either KeyPress or the OnKeyPress event handler it calls can suppress further processing of a character by setting the Key parameter to zero.
Note: The
Keyparameter is the character represented by the key that is pressed, not a Windows virtual key code.