将 Form 的 keypreview 设为 true
然后处理两个Form事件:OnKeyDown,OnKeyUp
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
IF KEY=ORD('6') then
speedbutton6.Perform(WM_LBUTTONDOWN,0,0);
end;
procedure TForm1.FormKeyUp(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
IF KEY=ORD('6') then
speedbutton6.Perform(WM_LBUTTONUP,0,0);
end;