1keyboard_callback(3)            Allegro manual            keyboard_callback(3)
2
3
4

NAME

6       keyboard_callback  -  User specified keyboard callback handler. Allegro
7       game programming library.
8

SYNOPSIS

10       #include <allegro.h>
11
12
13       extern int (*keyboard_callback)(int key);
14

DESCRIPTION

16       If set, this function is called by the keyboard handler in response  to
17       every  keypress.  It  is passed a copy of the value that is about to be
18       added  into  the  input  buffer,  and  can  either  return  this  value
19       unchanged, return zero to cause the key to be ignored, or return a mod‐
20       ified value to change what readkey() will later  return.  This  routine
21       executes in an interrupt context, so it must be in locked memory. Exam‐
22       ple:
23
24          int enigma_scrambler(int key)
25          {
26             /* Add one to both the scancode and ascii values. */
27             return (((key >> 8) + 1)
28          }
29          END_OF_FUNCTION(enigma_scrambler)
30
31          ...
32
33             install_timer();
34             LOCK_FUNCTION(enigma_scrambler);
35             install_keyboard();
36             keyboard_callback = enigma_scrambler;
37
38       Note that this callback will be ignored if you  also  set  the  unicode
39       keyboard callback.
40
41

SEE ALSO

43       install_keyboard(3),  readkey(3),  ureadkey(3),  keyboard_ucallback(3),
44       keyboard_lowlevel_callback(3)
45
46
47
48Allegro                          version 4.2.3            keyboard_callback(3)
Impressum