Category : Pascal Source Code
Archive   : WHEELS.ZIP
Filename : KEYBOARD.PAS

 
Output of file : KEYBOARD.PAS contained in archive : WHEELS.ZIP
{@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
The purchaser of these procedures and functions may include them in COMPILED
programs freely, but may not sell or give away the source text.

If the function KeyBoard is invoked with the [W]ait parameter, it
WAITS for a key to be pressed. If [N]o wait, it returns zero if
there's nothing in the keyboard buffer, or calls KeyBoard('W') if
there is something. The return is an integer--its low byte is the
ASCII code of the key pressed (zero if a "special" code key) and
its high byte is the scan code. If you call for [N]o wait and no
key was pressed, both high and low bytes will be zero.

Note that the file SCANCODE.DAT contains a screen picture of the
keyboard scan codes and a chart of the special codes.

}
{$I regpack.typ}
{$I keyboard.lib}
var
TheseCodes : integer;
ASCIIcode, ScanCode : byte;
ThisCharacter : char;

begin
WriteLn('Press a key to begin. Press Escape to end.');
repeat
TheseCodes := KeyBoard('W');
ASCIIcode := (TheseCodes shl 8) shr 8;
ScanCode := TheseCodes shr 8;

{ NOTE: I have used "shl" and "shr" here to get the high and low bytes.
These will be familiar to Assembly language programmers. They mean
"shift left" and "shift right". "shl " is a left shift of bits.
The highest bits are "pushed off" the top end, and zeroes are
tacked on the low end. Thus, if a 16-bit integer is shown by
HHHHHHHHLLLLLLLL, (the Hs begin the High 8 bits and the Ls the Low)
after a "shl 8" it will look like "LLLLLLLL00000000", and after being
shifted 8 right again, it will be "00000000LLLLLLLL". If we just
"shr 8" to start with, we get "00000000HHHHHHHH". SHR and SHL are
invaluable any time you need to do individual bit manipulation.}

if ASCIIcode = 0 then
WriteLn('Character is "special"')
else WriteLn('Character is ',chr(ASCIIcode));
WriteLn('Scan Code is ',ScanCode);
WriteLn;
until (ASCIIcode = 27) and (ScanCode = 1);
end.

  3 Responses to “Category : Pascal Source Code
Archive   : WHEELS.ZIP
Filename : KEYBOARD.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/