在Form1的OnKeyDown里:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then SpeedButton1.Down := not SpeedButton1.Down;
end;
Good!
但最好在KeyUp属性里再来一下
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If key=vk_Space then SpeedButton1.Down:=not SpeedButton1.Down;
end;
就完全实现了单击键盘是相应的SpeedButton按下效果。