Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiFiremonkeyIOSOSXWindows

List Of All Virtual Key Codes For OnKeyDown And OnKeyUp In Delphi XE6 Firemonkey On Android And IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE6 Firemonkey Virtual Key Codes | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSIf you are building any kind of cross platform app where you use the keyboard you will probably need to know the various virtual key code constants which are listed in the System.UITypes unit in Delphi XE6 Firemonkey. These key codes also apply to Delphi XE5 and AppMethod. Keys like the hardware back button on your Android device are listed here as well as arrow keys and the like. You can compare the virtual key code that you want to the Key parameter in the OnKeyUp and OnKeyDown events of each control. Keep in mind that there is also the OnTyping event which is fired on IOS in addition to the usual OnKeyUp and OnKeyDown events. If your OnKeyUp and OnKeyDown events are not working for you on IOS try OnTyping instead. To use the virtual key codes you can set up a case statement on the Key parameter on OnKeyUp and OnKeyDown. You can cancel out a key press by setting the Key parameter to 0. Also keep in mind that there is a second parameter called KeyChar in the OnKeyUp and OnKeyDown events. I have had good success with the following code (on Windows at least):
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
begin
case KeyChar of
'x':
begin
// x pressed
end;
end;
case Key of
vkUp:
begin
// up pressed
end;
vkDown:
begin
// down pressed
end;
vkLeft:
begin
// left pressed
end;
vkRight:
begin
// right pressed
end;
end;
end;

Head over and check out the full list of virtual key codes on Embarcadero’s webiste for use with Delphi XE6 Firemonkey.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLinuxOSXShowcaseWindows

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging

DelphiFiremonkeyShowcaseUtilityWindows

Unleashing Creativity With Song Writer AI: A Deep Dive

DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

Leave a Reply