if (chr(Key) in [’J’,’j’]) and (image2.Left>10 )then
image2.Left:=image2.Left-20;
if (chr(Key)in [’L’,’l’])and(image2.Left<420) then
image2.Left:=image2.Left+20;
其中image2是我方军舰图像控件的名称,chr(Key) in [’J’,’j’]用于判断用户是否按下键盘的’J’,’j’按键,当用户按下’J’,’j’按键后当image2的位置不在窗体最左边时image2向左移动20个单位,chr(Key) in [’L’,’l’]用于判断用户是否按下键盘的’L’,’l’按键,当用户按下’L’,’l’按键后当image2的位置不在窗体最右边时image2向右移动20个单位。