home *** CD-ROM | disk | FTP | other *** search
- { KEYTEST.PAS }
- Program KeyTest;
- Uses
- Crt;
- Var
- Code : Integer;
-
-
- Function GetKey : Integer;
- { Pauses for input of a single keystroke from the keyboard and returns
- the ASCII value. In the case where an Extended keyboard key is pressed,
- GetKey returns the ScanCode + 256. The Turbo Pascal ReadKey function
- is called to perform the keystroke input. This routine returns a 0
- when an Extended key has been typed (e.g. left or right arrow) and we
- must read the next byte to determined the Scan code.
- }
- Var
- Ch : Char;
- Begin
- Ch := ReadKey;
- If Ord(Ch) <> 0 Then
- GetKey := Ord(Ch) { Return normal ASCII value }
- Else
- Begin
- { Read the DOS Extended SCAN code that follows }
- GetKey := Ord(ReadKey) + 256;
- End;
- End;{GetKey}
-
- Begin
- Repeat
- Code := GetKey;
- Writeln(Code);
- Until Code = 27;
- End.