02-11-2007, 03:37 AM
I don't remember if I posted this question before or not, but, I'm still in the dark on this subject.
In a program I'm working on, I use a key to move a sprite to the right, and another ket to move it to the left. But, if I hold down the key, when I lift my finger, and try to go in the opposite direction, the sprit continues to go in the first direction for a while, then, finally, changes direction to the newly desired one. I understand that the keyboard buffer, which holds up to 15 keypresses, has to be cleared out to avoid this. My question, then, is, how do I clear out the keyboard buffer, if, indeed, that is what has to be done.
REVISED 7:51 pm Central Time:
I think I have found a way!!! Here it is:
In a program I'm working on, I use a key to move a sprite to the right, and another ket to move it to the left. But, if I hold down the key, when I lift my finger, and try to go in the opposite direction, the sprit continues to go in the first direction for a while, then, finally, changes direction to the newly desired one. I understand that the keyboard buffer, which holds up to 15 keypresses, has to be cleared out to avoid this. My question, then, is, how do I clear out the keyboard buffer, if, indeed, that is what has to be done.
REVISED 7:51 pm Central Time:
I think I have found a way!!! Here it is:
Code:
'Ralph's keyboard buffer cleanout:
FOR I = 1 TO 15
K$ = INKEY$
NEXT I
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.