Keyboard

ALLEGRO_KEYBOARD

typedef struct ALLEGRO_KEYBOARD ALLEGRO_KEYBOARD;

This is an abstract data type representing the physical keyboard. Keyboard objects are also event sources so can be casted to ALLEGRO_EVENT_SOURCE*.

ALLEGRO_KEYBOARD_STATE

typedef struct ALLEGRO_KEYBOARD_STATE

This is a structure that is used to hold a "snapshot" of a keyboard's state at a particular instant. It contains the following publically readable fields:

display - points to the display that had keyboard focus at the time the state was saved. If no display was focused, this points to NULL.

You cannot read the state of keys directly. Use the function al_key_down.

Key codes

ALLEGRO_KEY_A ... ALLEGRO_KEY_Z, ALLEGRO_KEY_0 ... ALLEGRO_KEY_9, ALLEGRO_KEY_PAD_0 ... ALLEGRO_KEY_PAD_9, ALLEGRO_KEY_F1 ... ALLEGRO_KEY_F12, ALLEGRO_KEY_ESCAPE, ALLEGRO_KEY_TILDE, ALLEGRO_KEY_MINUS, ALLEGRO_KEY_EQUALS, ALLEGRO_KEY_BACKSPACE, ALLEGRO_KEY_TAB, ALLEGRO_KEY_OPENBRACE, ALLEGRO_KEY_CLOSEBRACE, ALLEGRO_KEY_ENTER, ALLEGRO_KEY_SEMICOLON, ALLEGRO_KEY_QUOTE, ALLEGRO_KEY_BACKSLASH, ALLEGRO_KEY_BACKSLASH2, ALLEGRO_KEY_COMMA, ALLEGRO_KEY_FULLSTOP, ALLEGRO_KEY_SLASH, ALLEGRO_KEY_SPACE, ALLEGRO_KEY_INSERT, ALLEGRO_KEY_DELETE, ALLEGRO_KEY_HOME, ALLEGRO_KEY_END, ALLEGRO_KEY_PGUP, ALLEGRO_KEY_PGDN, ALLEGRO_KEY_LEFT, ALLEGRO_KEY_RIGHT, ALLEGRO_KEY_UP, ALLEGRO_KEY_DOWN, ALLEGRO_KEY_PAD_SLASH, ALLEGRO_KEY_PAD_ASTERISK, ALLEGRO_KEY_PAD_MINUS, ALLEGRO_KEY_PAD_PLUS, ALLEGRO_KEY_PAD_DELETE, ALLEGRO_KEY_PAD_ENTER, ALLEGRO_KEY_PRINTSCREEN, ALLEGRO_KEY_PAUSE, ALLEGRO_KEY_ABNT_C1, ALLEGRO_KEY_YEN, ALLEGRO_KEY_KANA, ALLEGRO_KEY_CONVERT, ALLEGRO_KEY_NOCONVERT, ALLEGRO_KEY_AT, ALLEGRO_KEY_CIRCUMFLEX, ALLEGRO_KEY_COLON2, ALLEGRO_KEY_KANJI, ALLEGRO_KEY_LSHIFT, ALLEGRO_KEY_RSHIFT, ALLEGRO_KEY_LCTRL, ALLEGRO_KEY_RCTRL, ALLEGRO_KEY_ALT, ALLEGRO_KEY_ALTGR, ALLEGRO_KEY_LWIN, ALLEGRO_KEY_RWIN, ALLEGRO_KEY_MENU, ALLEGRO_KEY_SCROLLLOCK, ALLEGRO_KEY_NUMLOCK, ALLEGRO_KEY_CAPSLOCK ALLEGRO_KEY_EQUALS_PAD, ALLEGRO_KEY_BACKQUOTE, ALLEGRO_KEY_SEMICOLON2, ALLEGRO_KEY_COMMAND

Keyboard modifier flags

ALLEGRO_KEYMOD_SHIFT
ALLEGRO_KEYMOD_CTRL
ALLEGRO_KEYMOD_ALT
ALLEGRO_KEYMOD_LWIN
ALLEGRO_KEYMOD_RWIN
ALLEGRO_KEYMOD_MENU
ALLEGRO_KEYMOD_ALTGR
ALLEGRO_KEYMOD_COMMAND
ALLEGRO_KEYMOD_SCROLLLOCK ALLEGRO_KEYMOD_NUMLOCK
ALLEGRO_KEYMOD_CAPSLOCK
ALLEGRO_KEYMOD_INALTSEQ
ALLEGRO_KEYMOD_ACCENT1
ALLEGRO_KEYMOD_ACCENT2
ALLEGRO_KEYMOD_ACCENT3
ALLEGRO_KEYMOD_ACCENT4

al_get_keyboard

ALLEGRO_KEYBOARD *al_get_keyboard(void)

Return a pointer to an object representing the keyboard, that can be used as an event source.

al_get_keyboard_state

void al_get_keyboard_state(ALLEGRO_KEYBOARD_STATE *ret_state)

Save the state of the keyboard specified at the time the function is called into the structure pointed to by RET_STATE.

al_install_keyboard

bool al_install_keyboard(void)

Install a keyboard driver. Returns true if successful. If a driver was already installed, nothing happens and true is returned.

al_is_keyboard_installed

bool al_is_keyboard_installed(void)

Returns true if al_install_keyboard was called successfully.

al_key_down

bool al_key_down(const ALLEGRO_KEYBOARD_STATE *state, int keycode)

Return true if the key specified was held down in the state specified.

al_keycode_to_name

const char *al_keycode_to_name(int keycode)

Converts the given keycode to a description of the key.

al_set_keyboard_leds

bool al_set_keyboard_leds(int leds)

Overrides the state of the keyboard LED indicators. Set to -1 to return to default behavior. False is returned if the current keyboard driver cannot set LED indicators.

al_uninstall_keyboard

void al_uninstall_keyboard(void)

Uninstalls the active keyboard driver, if any. This will automatically unregister the keyboard event source with any event queues.

This function is automatically called when Allegro is shut down.

Last updated: 2009-07-05 05:34:26 UTC