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

NAME

6       key  -  Array  of  flags indicating key state. Allegro game programming
7       library.
8

SYNOPSIS

10       #include <allegro.h>
11
12
13       extern volatile char key[KEY_MAX];
14

DESCRIPTION

16       Array of flags indicating the state of each key, ordered  by  scancode.
17       Wherever  possible  these values will be updated asynchronously, but if
18       keyboard_needs_poll() returns TRUE, you must  manually  call  poll_key‐
19       board()  to update them with the current input state. The scancodes are
20       defined in allegro/keyboard.h as a series of KEY_* constants  (and  are
21       also listed below). For example, you could write:
22
23          if (key[KEY_SPACE])
24             printf("Space is pressed\n");
25
26       Note  that the array is supposed to represent which keys are physically
27       held down and which keys are not, so it is semantically read-only.
28
29       These are the keyboard scancodes:
30
31          KEY_A ... KEY_Z,
32          KEY_0 ... KEY_9,
33          KEY_0_PAD ... KEY_9_PAD,
34          KEY_F1 ... KEY_F12,
35
36          KEY_ESC, KEY_TILDE, KEY_MINUS, KEY_EQUALS,
37          KEY_BACKSPACE, KEY_TAB, KEY_OPENBRACE, KEY_CLOSEBRACE,
38          KEY_ENTER, KEY_COLON, KEY_QUOTE, KEY_BACKSLASH,
39          KEY_BACKSLASH2, KEY_COMMA, KEY_STOP, KEY_SLASH,
40          KEY_SPACE,
41
42          KEY_INSERT, KEY_DEL, KEY_HOME, KEY_END, KEY_PGUP,
43          KEY_PGDN, KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN,
44
45          KEY_SLASH_PAD, KEY_ASTERISK, KEY_MINUS_PAD,
46          KEY_PLUS_PAD, KEY_DEL_PAD, KEY_ENTER_PAD,
47
48          KEY_PRTSCR, KEY_PAUSE,
49
50          KEY_ABNT_C1, KEY_YEN, KEY_KANA, KEY_CONVERT, KEY_NOCONVERT,
51          KEY_AT, KEY_CIRCUMFLEX, KEY_COLON2, KEY_KANJI,
52
53          KEY_LSHIFT, KEY_RSHIFT,
54          KEY_LCONTROL, KEY_RCONTROL,
55          KEY_ALT, KEY_ALTGR,
56          KEY_LWIN, KEY_RWIN, KEY_MENU,
57          KEY_SCRLOCK, KEY_NUMLOCK, KEY_CAPSLOCK
58
59          KEY_EQUALS_PAD, KEY_BACKQUOTE, KEY_SEMICOLON, KEY_COMMAND
60
61       Finally, you may notice an `odd' behaviour of the KEY_PAUSE  key.  This
62       key  only  generates  an  interrupt  when it is pressed, not when it is
63       released.  For this reason, Allegro pretends the pause key is a `state'
64       key, which is the only way to make it usable.
65
66

SEE ALSO

68       install_keyboard(3), poll_keyboard(3), key_shifts(3)
69
70
71
72Allegro                          version 4.2.3                          key(3)
Impressum