Hallo,
Das kannst du mit MapVirtualKey / ToAscii realisieren.
(funktioniert auch mit alt gr + ....)
Delphi-Quellcode:
function GetCharFromVirtualKey(Key: Word): string;
var
KBDState: TKeyboardState;
asciiRes: Byte;
begin
GetKeyboardState(KBDState) ;
SetLength(Result, 2) ;
asciiRes := ToAscii(key, MapVirtualKey(key, 0), KBDState, @Result[1], 0) ;
case asciiRes of
0: Result := ''; // The specified virtual key has no translation for the current state of the keyboard.
1: SetLength(Result, 1) ; // One Windows character was copied to the buffer.
2:; // Two characters were copied to the buffer. This usually happens when a dead-key character (accent or diacritic) stored in the keyboard layout cannot be composed with the specified virtual key to form a single character.
end;
end;
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Caption := GetCharFromVirtualKey(Key) ;
end;