📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
Shape1: TShape;
procedure Timer1Timer(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Label1.Caption='向上' then
Shape1.Top:=Shape1.Top-5;
if Label1.Caption='向左' then
Shape1.Left:=Shape1.Left-5;
if Label1.Caption='向下' then
Shape1.Top:=Shape1.Top+5;
if Label1.Caption='向右' then
Shape1.Left:=Shape1.Left+5;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=32 then Label1.Caption:='停止';
if Key=37 then Label1.Caption:='向左';
if Key=38 then Label1.Caption:='向上';
if Key=39 then Label1.Caption:='向右';
if Key=40 then Label1.Caption:='向下';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -