procedure KeyDown(var Key: Word; var KeyChar: WideChar; Shift: TShiftState); virtual;
virtual void __fastcall KeyDown(System::Word &Key, System::WideChar &KeyChar, System::Classes::TShiftState Shift);
Provides a response when a key is pressed down while the control has the keyboard focus.
TCommonCustomForm and descendant of TControl classes--like TCustomGrid--call KeyDown from their methods handling key pressing. They decode the message parameters into the key code, character code, and shift state. They pass them into the called KeyDown method in the
Shift parameters, respectively:
Is the scan code of the pressed keyboard key or
If a pressed key combination can be a shortcut, then
Physical scan codes of the same key can differ under different platforms (Windows or iOS). Platform-specific units (for example FMX.Platform.Mac.pas) should translate native scan codes to corresponding Windows codes defined in the UITypes unit. For example,
Is the pressed character (digit) or
If a pressed key combination can be treated as a printable character or digit, then
Indicates which shift keys--SHIFT, CTRL, ALT, and CMD (only for Mac)--were down when the specified key was pressed with the control in focus.
If the control has successfully processed the pressed key combination and no additional processing is required, then KeyDown assigns
Key = 0 and
KeyChar = #0.
Override the protected KeyDown method to provide other responses when a key is down while the control has keyboard input focus.
See TCommonCustomForm.KeyDown for more information about parameters.