Message-Id: <335E14D1.19CF@canvaslink.com> Date: Wed, 23 Apr 1997 09:55:29 -0400 From: Tom Grandgent Reply-To: tgrand AT canvaslink DOT com Organization: Canvas Link, Inc. Mime-Version: 1.0 To: convidat AT upvnet DOT upv DOT es Cc: djgpp AT delorie DOT com Subject: Re: Clear key buffer Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk >>I suggest to do it the usual way: >> >> #include >> while (kbhit ()) >> getch (); >> >>This clears the keyboard buffer, no matter what TSR has taken over >>Int 16h. It might be slower, but how many times per second do you >>need to clear the keyboard buffer, anyway? >The code can't be slow... I'm developing a game, and I need to clear the >buffer every 6/7 times, to avoid those noising beeps... If you're developing a game, it sounds like you're taking the wrong approach if you need to clear the buffer at all. You need to take over the keyboard interrupt! I suggest using Allegro, or at least looking at how it was done there. Basically, you need to stop the BIOS from handling the keyboard and put in your own code. So when you have installed your own keyboard interrupt handler, the buffer is emptied as soon as stuff goes into it. For example, the normal method seems to be to have an array containing the states for the keys on the keyboard. When you detect a state change (key up or key down) in your interrupt handler, you modify the array accordingly so that your program can just access that array. See what I'm saying? Or maybe you've already taken this approach. :) Tom Grandgent tgrand AT canvaslink DOT com Canvas Link, Inc.