I'm trying to detect when a F key, like F1 is pressed on my form.
I've set the form's KeyPreview property to True.
I've tried a few variations from tips I've found, but none work.
This works if I change the #112 to 65 and press A:
But #112 (ASCII for F1??) does not, and any mention of VK_F1 gives an error basically saying non integer.
How do I get this to work?
Steve (Delphi 2007 & XP)
I've set the form's KeyPreview property to True.
I've tried a few variations from tips I've found, but none work.
This works if I change the #112 to 65 and press A:
Code:
procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key in [#112] then Label7.Caption := 'F1 pressed';
key := #0;
end;
But #112 (ASCII for F1??) does not, and any mention of VK_F1 gives an error basically saying non integer.
How do I get this to work?
Steve (Delphi 2007 & XP)