FMX.Controls.TControl.KeyDown

Aus RAD Studio API Documentation
Wechseln zu: Navigation, Suche

Delphi

procedure KeyDown(var Key: Word; var KeyChar: WideChar; Shift: TShiftState); virtual;

C++

virtual void __fastcall KeyDown(System::Word &Key, System::WideChar &KeyChar, System::Classes::TShiftState Shift);

Eigenschaften

Typ Sichtbarkeit Quelle Unit Übergeordnet
procedure
function
protected
FMX.Controls.pas
FMX.Controls.hpp
FMX.Controls TControl


Description

Provides a response when a key is pressed down while the control has the keyboard focus.

If the pressed key is the Applications key (Key = vkApps), then KeyDown shows the context menu of the control. Otherwise, KeyDown calls the OnKeyDown event handler if one is assigned.

TCommonCustomForm und abgeleitete Klassen von TControl-Klassen – wie TCustomGrid – rufen KeyDown aus ihren Methoden zur Behandlung von Tasteneingaben auf. Diese Methoden decodieren die Botschaftsparameter in den Tastencode, Zeichencode und den Umschaltstatus. Diese werden in den Parametern Key, KeyChar bzw. Shift an die aufgerufene KeyDown-Methode übergeben:

Parameters Descriptions

Key

Is the scan code of the pressed keyboard key or $0. If a pressed key combination can be a shortcut, then Key <> 0 is a virtual key and KeyChar = #0. 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,

vkReturn = $0D; { 13 } corresponds to the RETURN keyboard key.
vkF2 = $71; { 113 } corresponds to the F2 keyboard key.

KeyChar

Is the pressed character (digit) or #0. Wenn eine gedrückte Tastenkombination als druckbares Zeichen oder druckbare Ziffer behandelt werden kann, dann ist Key = 0 und KeyChar enthält ein Symbol entsprechend der aktuellen Eingabesprache der Tastatur, dem Tastaturmodus (FESTSTELL- und NUM-Tasten), dem Shift-Status (Umschaltstatus) und dem IME-Status. Editoren können dieses Symbol in Text einfügen, der gerade bearbeitet wird.

Shift

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.

Überschreiben Sie die als protected deklarierte Methode KeyDown, um Reaktionen auf eine gedrückte Taste bereitzustellen, wenn das Steuerelement den Tastatureingabefokus besitzt.

See TCommonCustomForm.KeyDown for more information about parameters.

Warnung: Wenn Sie eine virtuelle (Bildschirm-)Tastatur auf Android-Geräten verwenden, sollten Sie sich nicht auf KeyEvents verlassen, um gedrückte Tasten, insbesondere Textzeichen, zu erkennen. KeyEvents erkennt jedoch abhängig von der Zielanwendung Tasten wie Return und Eingabe, aber nicht Löschen. Beachten Sie, dass andere Software-Eingabemethoden unabhängig von der Version möglicherweise nie KeyEvents senden.

See Also