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

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.

Exit mobile version