Mail Archives: djgpp/2000/08/03/03:52:14
On Wed, 2 Aug 2000, Florent wrote:
> I'm looking for the way to detect that a user hit the keys up and down
> (arrows)
>
> I do it with the function _bios_keybrd in bios.h
>
> If I use _NKEYBRD_READ as command of the bios function what value should I
> test for it ? when I test it with a small example
>
> unsigned char c=_bios_keybrd(_NKEYBRD_READ);
> printf("%d",c);
>
> when a down or up are hit only 224 came as value ... but what I want is to
> do the difference between those 2 keys ...
You are using a BIOS function for reading extended keys (that's what
_NKEYBRD_READ command does, as the library reference describes). Some
extended keys generate 2 bytes instead of 1: the first byte is E0h
(that's 224 in decimal) prefix, the second byte is the key code. So,
if you want to use this function, your code needs to read another byte
(by calling _bios_keybrd again) whenever it sees 224.
FWIW, I don't even understand why did you need to use _NKEYBRD_READ
instead of _KEYBRD_READ. Reading the arrow keys doesn't require to
distinguish extended keys, unless you want to handle the numeric
keypad specially. If you use _KEYBRD_READ, you will never see those
E0h prefixes.
- Raw text -