C Language Development Kit/Snippets/Input/WaitForKey

From OptiWiki

Jump to: navigation, search
Description Waits until any key of the keyboard is pressed.
Syntax
int WaitForKey( void );
Arguments None.
Returns The key that is pressed.
Remarks Function does not return as long as no key is pressed.
Example
#include "lib.h"
#include <stdio.h>
#include "input.h"  //Holds the input functions
 
void main( void )
{
    int key;
 
    for(;;)
    {
        printf("\fWaitForKey()\npress a key\nto continue");
        WaitForKey();
 
        printf("\fWaitForKeys()\npress Q1 or Q2\nto continue");
        WaitForKeys( 2, Q1_KEY, Q2_KEY );
    }
}


Views
Personal tools