delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/03/03:52:14

Date: Thu, 3 Aug 2000 08:55:36 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Florent <florent AT oih DOT rwth-aachen DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: code of up and down arrow ...
In-Reply-To: <8ma1hl$rfm$1@nets3.rz.RWTH-Aachen.DE>
Message-ID: <Pine.SUN.3.91.1000803085521.10519D-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019