Link to home
Start Free TrialLog in
Avatar of triplem
triplem

asked on

Pressing keyboard - newbie

I need something which finds out if the keyboard has been hit or not. Basically I want the computer to wait for a while (using a for loop), if so and so key has been pressed do this (which can happen more than once in the loop). However I don't want it to wait until a key has been pressed before continuing.. is there any function like this?

my program is something like:

while (alive)
{
 for (i=0; i<1000000; i++)
 {
 if (x has been pressed)
    do this;
 }
 do this;
}
ASKER CERTIFIED SOLUTION
Avatar of gj62
gj62

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you need a specific key (1) to be pressed just use read the key & if it's the one that Ur expectin' then continue or if U just want any key (2) use getch (); will do it...

e.g. (1)
char x;
read (x);
if (x == '1_char_expected') //or use it value in ascii
{
 ...
}

e.g. (2)
if (getch ())
{
 ...
}
Avatar of umangjoshi
umangjoshi

make use of bioskey() function