Benötigt wird ein TImage auf dem Formular, weiter muss die KeyPreview des Formulares auf True gestellt werden.
Delphi-Quellcode:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_LEFT: begin
Image1.Left := Image1.Left - 5;
Key := 0;
end;
VK_RIGHT: begin
Image1.Left := Image1.Left + 5;
Key := 0;
end;
VK_UP: begin
Image1.Top := Image1.Top - 5;
Key := 0;
end;
VK_DOWN: begin
Image1.Top := Image1.Top + 5;
Key := 0;
end;
end;
end;
Von sakura!
Grüsse, Daniel