C Language Development Kit/Functions/DownPressed

From OptiWiki

Jump to: navigation, search
Description This function returns the current state of the down key. The down key is the

button on the rigth of the trigger key. The down key can be either pressed or not pressed.

Syntax
int downpressed(void);
Arguments None
Returns
>= 1 The down key is pressed
0 The down key is not pressed
Remarks When the down key is pressed down this event is interpreted as a key stroke.

The key stroke is placed in the keyboard buffer as DOWN_KEY, so the function getchar() will return the key stroke as DOWN_KEY. The function downpressed() returns the current state of the down key. The function getchar() returns DOWN_KEY when a transition took place from not pressed to pressed.

Example
// 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);
 
        idle();
    }
}


Views
Personal tools