General Terminal

GtSetKeyFilter

Install a callback that filters input key codes

Syntax

Signature
void GtSetKeyFilter( ItemBlock block );

Arguments

block is called with the queued key code. Return a replacement code or 0 to discard the key. Pass NULL to remove the callback.

Return value

No return value.

Description

The filter runs when a key is consumed from the input buffer. It can normalize selected input before the application receives it.

Example

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

#include <stdio.h>

static int normalize( int key )
{
   return key == 'a' ? 'A' : key;
}

int main( void )
{
   puts( "Press a key. Lowercase a is converted to uppercase A." );
   GtSetKeyFilter( normalize );
   int key = Inkey( 5, NIL );
   GtSetKeyFilter( NULL );
   printf( "Key code: %d\n", key );

   return 0;
}

See also