Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!princeton!allegra!ulysses!faline!thumper!tr From: tr@thumper.UUCP Newsgroups: comp.lang.c Subject: Re: boolean function to tell if a key has been pressed Message-ID: <523@thumper.UUCP> Date: Fri, 20-Mar-87 08:42:30 EST Article-I.D.: thumper.523 Posted: Fri Mar 20 08:42:30 1987 Date-Received: Sun, 22-Mar-87 16:36:31 EST References: <10260@topaz.RUTGERS.EDU> Lines: 40 In article <10260@topaz.RUTGERS.EDU>, whoffman@topaz.UUCP writes: > > Hello, > > I am seeking a way to tell whether or not a key has been pressed on > a keyboard. i.e something like this: > > while (1) > { ...statements.... > if "a key has been pressed" {...statements} > ...statements...} > > the problem i keep running into is that getc,getchar etc..all WAIT for > a key to be pressed. I would just like to see IF one has been pressed. > Any help on this would be greatly appreciated. Thanks in advance... > > William R. Hoffman Well, I gather you are using a minicomputer, so the routine I use won't work for you. In MS-DOS, the Microsoft and Lattice compilers give you functions called kbkit() which take no arguments and return either TRUE or FALSE. Too bad because they work. Anyway, why don't you use getchar(), check for EOF, and if there is a character, unget() the character? This would push it back onto the input stream. Tom Reingold INTERNET: tr@bellcore.com -------- UUCP: ---- watmath!clyde!bellcore\ ucbvax\ \ lll-lcc\ ihnp4!mhuxt!ulysses!faline!flash!tr seismo!rutgers!mit-eddie!allegra/ -- Tom Reingold Internet: tr@bellcore.com Uucp: ..!allegra!ulysses!faline!flash!tr