RAD Studio VCL Reference
TWinControl.KeyPress Method

Respond to keyboard input.

procedure KeyPress(var Key: Char); dynamic;
__fastcall KeyPress(Char Key);

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 Key parameter is the character represented by the key that is pressed, not a Windows virtual key code.


Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!