Path: utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!rpi!crdgw1!ge-dab!tarpit!bilver!alex From: alex@bilver.UUCP (Alex Matulich) Newsgroups: comp.sys.amiga.tech Subject: Re: Reading the keyboard without a window. Message-ID: <515@bilver.UUCP> Date: 3 Mar 90 16:40:31 GMT References: <1237@mindlink.UUCP> Reply-To: alex@bilver.UUCP (Alex Matulich) Organization: W. J. Vermillion, Winter Park, FL Lines: 34 >................ > If you hold down a key it begins to repeat, I want to ignore the messages > sent to me by the autorepeat after you have lifted your finger from the > key. How do I do that if they come faster than I can process them ? The way I do it is simple, provided the keystrokes are being read from the console. I wrote a little function called clearkbd(), which uses the function ConMayGetChar() found in the RKM Libraries manual. It looks like this: char inkey() /* get a keypress, or return 0 if no key has been pressed */ { char key; key = ConMayGetChar(consoleReadPort, consoleReadMsg, &keybuffer[0]); return key; } void clearkbd() /* clear out the keyboard buffer */ { char key; while ((key = inkey()) != '\0'); } clearkbd() is called to clear out all unused keystrokes from the keyboard buffer before getting the next keystroke. The effect of this is that auto-repeats will only go as fast as my program gets characters. -- /// Alex Matulich /// Unicorn Research Corp, 4621 N Landmark Dr, Orlando, FL 32817 \\\/// alex@bilver.UUCP ...uunet!tarpit!bilver!alex \XX/ From BitNet use: bilver!alex@uunet.uu.net