我正在尝试拥有一个键控摄像头。TForm 没有 Onkeypress,所以我如何从键盘读取这个输入?
procedure TForm2.FormKeyPress(Sender: TObject; var Key: Char);
var
ok: boolean;
begin
ok := true;
case Key of
'a': camera1.Position.y:=camera1.Position.y+1;
'A': camera1.Position.y:=camera1.Position.y+1;
'd': camera1.Position.y:=camera1.Position.y-1;
'D': camera1.Position.y:=camera1.Position.y-1;
'w': camera1.Position.X:=camera1.Position.X-1;
'W': camera1.Position.X:=camera1.Position.X-1;
'x': camera1.Position.X:=camera1.Position.X+1;
'X': camera1.Position.X:=camera1.Position.X+1;
'q': camera1.RotationAngle.z := camera1.RotationAngle.z-1;
'Q': camera1.RotationAngle.z := camera1.RotationAngle.z-1;
'e': camera1.RotationAngle.z := camera1.RotationAngle.z+1;
'E': camera1.RotationAngle.z := camera1.RotationAngle.z+1;
'z': camera1.Position.z:=camera1.Position.z+1;
'Z': camera1.Position.z:=camera1.Position.z+1;
'c': camera1.Position.z:=camera1.Position.z-1;
'C': camera1.Position.z:=camera1.Position.z-1;
else
ok := false;
end; {case}
//if ok then
// Invalidate;
positionChange(camera1);
RotationAngleChange(camera1);
end;