delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/09/06:04:11

Date: Tue, 9 Jan 2001 13:02:22 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Karsten Schmidt <Karsten DOT Schmidt AT student DOT uni-ulm DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: Problem with kbhit()
In-Reply-To: <3A5AE4E7.85120936@student.uni-ulm.de>
Message-ID: <Pine.SUN.3.91.1010109130029.20795A-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 Tue, 9 Jan 2001, Karsten Schmidt wrote:

> I'm trying to detect when the user hits the keyboard. 
> Unfortunately the kbhit() function is always true 
> after the first key has been hit. Therefore I'm not able to
> detect any further hits.

You need to remove the key from the keyboard queue; kbhit doesn't do
that.  So the key stays in the queue and kbhit reports a non-zero
value forever.

You can remove the key from the queue with a call to getkey, for
example.

- Raw text -


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