Program KEYB;

{ Draws the numeric keypad of the IBM PC keyboard }

var l: array[1..20] of real;
    c: array[1..20] of real;
    l1,c1,i,j: real;
    top,bot: string;


Procedure DRAWKEY(i,a: real);

{ Draws a key with i=key number, a=attribute }

Var h,w: real;

Begin
  if (i<>18) and (i<>20) then
     begin
       if i=16
          then begin h:=6; w:=6; end
          else if i=17
                  then begin h:=3; w:=12; end
                  else begin h:=3; w:=6; end;
       if a<>0 then clearbox(l[i],c[i],h,w,a);
       box(l[i],c[i],h,w,1);
       cursor(l[i]+1,c[i]+1); write(substr(top,(i-1)*4+1,4));
       if substr(bot,i,1)<>' ' then
          begin cursor(l[i]+2,c[i]+1); write(substr(bot,i,1)); end;
     end;
end;

Begin
top:='Esc Num ScrLSysRHome   PgUpPrtS <-      ->     End    PgDn    Ins     Del     ';
bot:='    789*456-123+0 . ';
l1:=3; c1:=30;
clear;
for i:=1 to 5 do for j:=1 to 4 do l[(i-1)*4+j]:=l1+(i-1)*3;
for i:=1 to 5 do for j:=1 to 4 do c[(i-1)*4+j]:=c1+(j-1)*6;

for i:=1 to 20 do drawkey(i,0);

for i:=1 to 20 do
begin
  drawkey(i,1);
  for j:=1 to 200 do; { wait loop }
end;

cursor(22,1);

end.
