Article View: comp.sys.amiga.tech
Article #14013Re: Reading the keyboard without a window.
From: Alex Matulich
Date: Sat, 03 Mar 1990 16:40
Date: Sat, 03 Mar 1990 16:40
34 lines
1649 bytes
1649 bytes
>................
> 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
Technical Details
Message-ID:
<515@bilver.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!rpi!crdgw1!ge-dab!tarpit!bilver!alexReferences:
<1237@mindlink.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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