kbhit

Availability All terminals
Description This function checks to see if a keystroke is available.
Syntax unsigned int kbhit( void );
Arguments None
Returns When a keystroke is available, kbhit() returns a non-zero integer; zero is returned otherwise.
Remarks Use the Idle() function when kbhit() is used to wait for keyboard input.
When a user wants to wait for a key press, it is advised to call ResetKey() first, in order to be sure that a previous key, still in the keyboard buffer, doesn't cause kbhit() to return TRUE.
Example
#include <stdio.h>
#include "lib.h"

void main( void )
{
    int color = GREEN;

    for(;;)
    {
        printf("\nPress any key");

        ResetKey();
         
        while(!kbhit())
            Idle();

        GoodReadLed(color, 50);        // ON, 1 second

        color = (color == GREEN) ? RED : GREEN;
    }
}