home *** CD-ROM | disk | FTP | other *** search
- program keytest; (* Testing the input of functionkeys in TURBO-PASCAL *)
-
- (******************************************)
- (* Written by Wolfgang Siebeck, 72446,415 *)
- (* Date: 01/09/85 *)
- (* With greetings from West Germany *)
- (******************************************)
-
- var
- key: char;
- fkey: boolean;
- special: byte;
- n: integer;
-
- const
- keystr: string[40]=';<=>?@ABCDTUVWXYZ[\]^_`abcdefghijklmnopq';
- (* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *)
- (* These are the second codes of functionkeys *)
-
- procedure inkey (var key: char; var fkey: boolean);
- begin
- read (kbd, key);
- fkey:=false;
- if key = chr(27) then (* maybe a functionkey *)
- if keypressed then
- begin (* but only if keypressed *)
- fkey := true; (* set the flag *)
- read (kbd, key) (* and read the 2nd code *)
- end
- end; (* inkey *)
-
-
- (* Demopart of the program *)
- (* This demo accepts functionkey 1..40 or normal keys and dis- *)
- (* play the input on the screen. Functionkeys are displayed as *)
- (* <F1> thru <F40> in high intensity, all other keys are dis- *)
- (* played in low intensity. The alternate A..Z,0..9 are *)
- (* trapped by the errorsound, but may be included by appending *)
- (* their second codes to the const keystr. *)
- (* This version of inkey catches the difference between *)
- (* hitting a functionkey and hitting <ESC> followed by a normal *)
- (* key. *)
- (****************************************************************)
-
- begin
- writeln (' Hit ^C to abort program.');
- writeln;
- lowvideo;
- repeat
-
- repeat until keypressed; (* loop for demo purpose *)
- inkey (key,fkey); (* call the kernel *)
- if not fkey then write (key)
- else
- begin
- special := pos(key,keystr);
- if special > 0 then
- begin
- highvideo;
- write ('<F',special,'>');
- lowvideo;
- end
- else
- begin
- write ('<NOT DEFINED>');
- for n:=100 to 500 do
- begin
- sound (n*10);
- end;
- nosound;
- end;
- end;
- until (true=false);
- end.
-