I'm failing to see why Key is set to 0 if KeyChar is present
Short answer, because that's how FMX.Platform.Win.pas
is coded:
WM_CHAR:
begin
ch := WideChar(wParam);
key := 0;
LForm.KeyDown(key, ch, KeyDataToShiftState(lParam));
LForm.KeyUp(key, ch, KeyDataToShiftState(lParam));
Result := 0;
end;
As for your problem, calling GetKeyState()
should do the trick:
procedure TMyForm.Edit1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
case KeyChar of
'0'..'9':
if GetKeyState(VK_NUMPAD0 + Ord(KeyChar) - Ord('0')) < 0 then
ShowMessage('Number pad ' + KeyChar + ' pressed')
else
ShowMessage('Normal ' + KeyChar + ' pressed');
end;
end;