General Terminal

GtSetKeyRead

Install a callback that runs before input is read

Syntax

Signature
void GtSetKeyRead( ItemBlock block );

Arguments

block is called with 0 before reading buffered input. Return a nonzero key code to supply input, or 0 to read normally. Pass NULL to remove the callback.

Return value

No return value.

Description

The callback can supply a key directly. This example provides a key once and removes the callback immediately after reading it.

Example

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

#include <stdio.h>

static int supplyKey( int value )
{
   ( void )value;
   return 'A';
}

int main( void )
{
   GtSetKeyRead( supplyKey );
   int key = Inkey( NIL, NIL );
   GtSetKeyRead( NULL );
   printf( "Key code: %d\n", key );

   return 0;
}

See also