1 program KeyTest;
2 
3 uses GRX;
4 
5 var
6   MouseMode, DrawMode,
7   m, x, y, co : Integer;
8   evt: GrMouseEvent;
9   Key : Char;
10   Finito : boolean;
11 
12 procedure MouseRoutine;
13    var st: String[80];
14 begin
15   if (evt.Flags and Gr_M_KeyPress) > 0 then begin
16     Key := Chr (evt.Key and $FF);
17     writestr(st,'Key :', Key:2, Ord(Key):4, evt.Key mod 256: 4, evt.Key div 256: 4, evt.Key: 6);
18     GrTextXY(evt.x,evt.y,st,GrWhite,GrBlack);
19     case evt.Key of
20       81, 113 : Finito := true; {'Q', 'q'}
21     end;
22   end;
23 end;
24 
25 begin
26   x  := 640;
27   y  := 480;
28   co := 256;
29   m  := GrSetMode(Gr_Default_Graphics,x,y,co,0,0);
30 
31   if GrMouseDetect then begin
32     GrMouseEventMode(1);
33     GrMouseInit;
34     GrMouseDisplayCursor;
35     DrawMode  := 0;
36     MouseMode := 4;
37   end else
38     exit;
39 
40   GrTextXY(0,0,'Use ''Q'' to Quit',GrWhite,GrBlack);
41   repeat
42     Finito  := false;
43     GrMouseGetEventT(Gr_M_Event,@evt,0);
44     if evt.Flags > 0 then MouseRoutine;
45   until Finito
46 end.
47