Functions

NextKey

Inspect the next matching input event without consuming it

Syntax

Signature
int NextKey( void );

Arguments

No arguments.

Return value

The next matching event code, or 0 if none is available.

Description

Poll the first pending event without waiting. If the event passes the current mask, it is returned and stays available for `Inkey()`. A pending event excluded by the current mask can be discarded. Use `LastKey()` for the stored result of the preceding read.

Example

nextkey.c
#include "xdev-wtui.h"

#include <stdio.h>

int main( void )
{
   int peeked = 0;

   DispOut( "Press a key within five seconds.", NULL );
   for( int i = 0; i < 90 && peeked == 0; ++i )
   {
      peeked = NextKey();
      if( peeked == 0 )
         Tone( 0, 1 );
   }

   int received = Inkey( NIL, NIL );
   printf( "NextKey: %d, Inkey: %d\n", peeked, received );

   return 0;
}