| delorie.com/archives/browse.cgi | search |
| From: | "Al Morgan" <muaddib AT proaxis DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Trap Keyboard Events |
| Date: | Tue, 24 Aug 1999 01:38:36 -0700 |
| Organization: | Posted via Supernews, http://www.supernews.com |
| Lines: | 36 |
| Message-ID: | <rs4memh24u10@corp.supernews.com> |
| References: | <37C156BB DOT 4808 AT lords DOT com> |
| X-Complaints-To: | newsabuse AT supernews DOT com |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 5.00.2314.1300 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2314.1300 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
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]
Robinson S. <roby AT lords DOT com> wrote in message
news:37C156BB DOT 4808 AT lords DOT com...
> I've searched through some of the c faqs out there and could not find
> the answer to this question:
>
> How do I check if a key has been pressed on the keyboard while my
> program is running. It is a program that runs the win-ping command, so
> it may apply to win32s as well.
>
> --
>
> Robinson S.,
> mailto:roby AT lords DOT com
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |