Get ASCII code of pressed key

Posted in Manipulators

et KeyPreview property of Form to True and use onKeyDown event. This event has Key parameter. It is a ASCII code of key.

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  Label1.Caption:=Chr(Key)+' - '+IntToStr(Key);
end;