{*****************************}
{**      Arrow Key Demo     **}



Var  ch1,ch2 : char;
     escape : boolean;

Procedure Select_Arrow;
begin
 escape := false;
 case ch2 of
 #77 : writeln('Right Arrow ',ord(ch2));
 #75 : writeln('Left Arrow ',ord(ch2));
 #72 : writeln('Up Arrow ',ord(ch2));
 #80 : writeln('Down Arrow ',ord(ch2));
end;


end; {** procedure **}

Procedure Read_Arrow_Keys;
begin
 repeat until keypressed;
 Read(Kbd,ch1);
 if (ch1 = #27) and keypressed then
   begin
    Read(Kbd,ch2);
    Select_Arrow;
   end
  else escape := true;

end;


{** main **}
begin
 clrscr;
 gotoxy(25,1); write('Press Arrow Keys or ESC to Leave Program');
 writeln; writeln;
repeat
 Read_Arrow_Keys;
until escape = true;
end.