C Language Development Kit/Snippets/Input/WaitForKeys

From OptiWiki

Jump to: navigation, search
Description Waits until a key from the list is pressed.
Syntax
int WaitForKeys( int num, ... );
Arguments
int num

The amount of keys that are specified in the list.
...
Holds the list of key to react on.

Returns The key from the list that is pressed.
Remarks Function does not return if any other key is pressed then the ones from the list.
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