libtcoddocumentation

2.4.1. Blocking keyboard input

This function waits for the user to press a key. It returns the code of the key pressed as well as the corresponding character. See TCOD_key_t.
If the flush parameter is true, every pending keypress event is discarded, then the function wait for a new keypress.
If flush is false, the function waits only if there are no pending keypress events, else it returns the first event in the keyboard buffer.

static TCOD_key_t TCODConsole::waitForKeypress(bool flush)

TCOD_key_t TCOD_console_wait_for_keypress(bool flush)

console_wait_for_keypress(flush)

static TCOD_key_t TCODConsole::waitForKeypress(bool flush)

tcod.console.waitForKeypress(flush)

ParameterDescription
flushif true, all pending keypress events are flushed from the keyboard buffer. Else, return the first available event
Example:

TCOD_key_t key = TCODConsole::waitForKeypress(true);
if
( key.c == 'i' ) { ... open inventory ... }

TCOD_key_t key = TCOD_console_wait_for_keypress(true);
if
( key.c == 'i' ) { ... open inventory ... }

key = libtcod.console_wait_for_keypress(True)
if
key.c == ord('i') :

key = tcod.console.waitForKeypress(true)
if
key.Character == 'i' then ... open inventory ... end