Delphi偵測按鍵輸入

1. Form -> keyprivew = True
2.
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_down) or (key = 13) then begin // 如果按向下鍵或Enter
//key:=vk_tab;
Caption :=ActiveControl.Name;
SendMessage(getparentform(self).Handle,WM_NEXTDLGCTL,0,0);
end else if (key = vk_up) then begin // 如果按向上鍵
Caption :=ActiveControl.Name;
SendMessage(getparentform(self).Handle,WM_NEXTDLGCTL,1,0);
end;
if ssctrl in shift then
if key = vk_f11 then showmessage(‘按下Ctrl+F11’);
end;