Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!sunic!draken!d88-eli
From: d88-eli@nada.kth.se (Erik Liljencrantz)
Newsgroups: comp.lang.pascal
Subject: Re: Clearing the keyboard buffer
Message-ID: <1857@draken.nada.kth.se>
Date: 3 Oct 89 21:05:14 GMT
References: <1169@krafla.rhi.hi.is> <708@thor.wright.EDU> <246@usna.MIL> <2774@phred.UUCP>
Reply-To: d88-eli@nada.kth.se (Erik Liljencrantz)
Organization: Royal Institute of Technology, Stockholm, Sweden
Lines: 18

In article <2774@phred.UUCP> brianr@phred.UUCP (Brian Reese) writes:
[...]
>	var Ch : char;
>
>	while KeyPressed do Ch := ReadKey;
>
>I've used this many times, but often wondered if there is an interrupt to do
>the same thing.  Does anyone out there know?

Yes: INT 16h, function 0 (in AH) reads a scancode into AX. Normal characters
are returned in AL (easy to translate to CHAR), but if the key is an extended
key (like F1, PgUp...) AL is zero, and AH contains the scancode. (The ReadKey
function has to be called twice if the first call returned a null (i.e. #0).)

BTW: Check the interruptlist (INTER489) for this kind of information. INT 16
     covers several other keyboard functions.
-- 
Erik Liljencrantz     | "No silly quotes!!"
d88-eli@nada.kth.se   |  Embraquel D. Tuta