C Language Development Kit/Functions/UpPressed

From OptiWiki

Jump to: navigation, search
Description This function returns the current state of the up key. The up key is the button on the left of the trigger key. The up key can be either pressed or not pressed.
int uppressed(void);
Arguments None
>= 1 The up key is pressed.
0 The up key is not pressed.
Remarks When the up key is pressed up this event is interpreted as a key stroke. The key stroke is placed in the keyboard buffer as UP_KEY, so the function getchar() will return the key stroke as UP_KEY. The function uppressed() returns the current state of the up key. The function getchar() returns UP_KEY when a transition took place from not pressed to pressed.
// This example will sound the buzzer when the up or down key is pressed
#include "lib.h"
#include <stdio.h>
void main( void )
    printf("\fPress up\nor down key!");
    while( 1 )
        if( uppressed() )
            sound( TSTANDARD, VHIGH, SHIGH, 0);
        if( downpressed() )
            sound( TSTANDARD, VHIGH, SMEDIUM, 0);

Personal tools