Mail Archives: djgpp/2000/06/25/12:15:29
On Sun, 25 Jun 2000 11:33:51 -0400, "Redouane Zrari"
<zrari AT hotmail DOT com> wrote:
>Hello everyone.
>
>In a small program, I try to make an object move by the left and right
>arrow keys. I test them with bioskey(). The problem: even after
>having released the cursor, the object continues to move in the
>direction of the first pressed key (even if I press the other way). I
>had to understand that keypresses remain in the "keyboard buffer"
>but..... What to make of this?
>
>I use the Djgpp compiler.
>
>Thanks in advance
I haven't used bioskey(), but you need to "get" the keypress after you
have found out that the key was pressed; this pulls it out of the
"keyboard buffer".
Before I found Allegro, I used kbhit() to see if the user pressed a
key, then getch() to get it, through this function I wrote:
int GetKey()
{
int n;
if(!kbhit())
return 0;
n = getch();
if(n)
return n;
return getch() << 8;
}
It returns 0 for no keypress, the ASCII value of a standard key, or
the scancode (shifted left 8 bits) for an extended key.
--
Damian Yerrick
"I refuse to listen to those who refuse to listen to reason."
See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html
This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses. http://www.mcafee.com/
- Raw text -