Не корректно работает обработчик нажати клавиш KeyDown

Делаю программу, которая рисует массив точем, а затем двигает их разными способами. Нужно - по нажатию клавиш. Там, где выделено в листинге ниже, поставил sleep(10), только после этого точки стали двигаться по нажатию, но тем не менее “кто в лес, кто по дрова”… Если закомментировать sleep(10), то вообще двигается только один элемент массива. Это нормально? В каком месте может быть нетак!!!

//the beginning of class description
Program lb1;
uses GraphABC,Events;

Type  TPoint = class
private
          x,y,Vx,Vy: integer;
         col: color;
 public
      Constructor Create(InitX, InitY: Integer; InitColor: Color);
      Procedure Hide;
       Procedure Draw;
  Procedure SetCoords(NewX,NewY: integer);
  Procedure SetCoordsRandom(MaxX,MaxY: integer);
  Procedure SetCoordsBySpeed(dx,dy: integer);
  Procedure SetCoordsByRandomSpeed(dr: integer);
  Procedure MoveBySpeed(dx,dy: integer);
  Procedure MoveByRandomSpeed(dr: integer);
  Procedure KeyDown(key: integer);
  Procedure KeyUp(k: integer);
  Procedure SetCoordsByKeystroke;
  Procedure MoveByKeystroke;

end;

Constructor TPoint.Create(InitX, InitY: Integer; InitColor: Color); begin x := InitX; y := InitY; Vx:=0; Vy:=0; col := InitColor; end;

Procedure TPoint.Hide; begin PutPixel(x,y,clBlack); end;

Procedure TPoint.Draw; begin PutPixel(x,y,col); end;

Procedure TPoint.SetCoords(NewX,NewY: integer); begin x:=NewX; y:=NewY; end;

Procedure TPoint.SetCoordsRandom(MaxX,MaxY: integer); begin x:=Random(MaxX+1); y:=Random(MaxY+1); end;

Procedure TPoint.SetCoordsBySpeed(dx,dy: integer); begin x:=x+dx; y:=y+dy; end;

Procedure TPoint.SetCoordsByRandomSpeed(dr: integer); begin x:=x+Random(2dr+1)-dr; y:=y+Random(2dr+1)-dr; end;

Procedure TPoint.KeyDown(key: integer); begin case key of VK_Left: Vx:=-2; { влево } VK_Right: Vx:=2; { вправо } VK_Up: Vy:=-2; { вверх } VK_Down: Vy:=2; { вниз } VK_Escape: CloseWindow; { закрыть окно } end; end;

Procedure TPoint.KeyUp(k: integer); begin Vx:=0;Vy:=0; end;

Procedure TPoint.SetCoordsByKeystroke; begin OnKeyDown:=KeyDown; // вызов процедуры - обработчика события нажания клавиш OnKeyUP:=KeyUp; x:=x+vx; y:=y+vy; sleep(10); end;

Procedure TPoint.MoveBySpeed(dx,dy: integer); begin Hide; SetCoordsBySpeed(dx,dy); Draw; end;

Procedure TPoint.MoveByRandomSpeed(dr: integer); begin Hide; SetCoordsByRandomSpeed(dr); Draw; end;

Procedure TPoint.MoveByKeystroke; begin Hide; SetCoordsByKeystroke; sleep(10); Draw; end;

//the end of class description //the beginning program inicialization

Const n = 10; MaxX=800; MaxY=600;

Var MAS: Array [1…n] of TPoint; i,vx,vy:integer; f:boolean;

//the end program inicialization

Begin
Randomize; SetWindowTitle(‘лабораная-2’); SetWindowWidth(MaxX); SetWindowHeight(MaxY); Window.CenterOnScreen(); Window.IsFixedSize := true; Window.Clear(Color.black);

for i:=1 to n do begin MAS[i]:=TPoint.Create(Random(MaxX),Random(MaxY),clRandom); MAS[i].Draw; end; { f:=false; repeat for i:=1 to n do begin MAS[i].MoveByKeystroke; end; sleep(100); until f; }

{ f:=false; repeat for i:=1 to n do begin MAS[i].MoveBySpeed(2,2); end; sleep(100); until f; }

end.