www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/29/07:57:43

From: "Robinson S." <roby AT lords DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Trap Keyboard Events
Date: Sun, 29 Aug 1999 00:39:10 -0400
Organization: ICAN.Net Customer
Lines: 33
Message-ID: <37C8B96E.4BC9@lords.com>
References: <37C156BB DOT 4808 AT lords DOT com> <rs4memh24u10 AT corp DOT supernews DOT com>
NNTP-Posting-Host: dialin340.toronto.globalserve.net
Mime-Version: 1.0
X-Mailer: Mozilla 3.04 (Win95; U)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Al Morgan wrote:
> 
> I think what you want is...  "kbhit()".   It will return true when a key has
> been pressed, like this:
> 
> #include <iostream.h>
> #include <conio.h>        // kbhit is in there, i think it might be in
> stdlib.h too, not sure.
> 
> void main()
>     {
>     int n = 0;
>     while(!kbhit())
>         {
>         cout << n++ << endl;
>         }
>     }
> 
> This program will count from 0 to infinity until the user presses a key.
> 
> Is that what you were looking for?
>     Al [muaddib AT proaxis DOT com]


Thank u, the _kbhit() function from conio.h works (there seems to be no
kbhit() function--needs the _ at beginning). This maybe because of the
compiler I am using: lcc-win32.


-- 

Robinson S.,
mailto:roby AT lords DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019