ResetKey

Availability All terminals
Description This function clears the keyboard buffer.
Syntax void ResetKey( void );
Arguments None
Returns None
Remarks This function is useful when one wants to wait for a key press. Call this function to prevent a previous keystroke, still in the keyboard buffer, causing e.g. 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;
    }
}