< index < 2. Console < 2.3 Handling keyboard input | ===================================== 2.3.1 Non-blocking keyboard input ===================================== |

    C++ : static TCOD_key_t TCODConsole::checkForKeypress(int flags=TCOD_KEY_RELEASED)
    C   : TCOD_key_t TCOD_console_check_for_keypress(int flags)
    Py  : console_check_for_keypress(flags=KEY_RELEASED)

This function checks if the user has pressed a key. It returns the code of the key pressed as well as the corresponding character. See TCOD_key_t. If the user didn't press a key, this function returns the key code TCODK_NONE.
Note that key repeat only results in TCOD_KEY_PRESSED events.

Parameter | Description
--- | ---
flags | A filter for key events : TCOD_KEY_PRESSED : only keypress events are returned TCOD_KEY_RELEASED : only key release events are returnes TCOD_KEY_PRESSED|TCOD_KEY_RELEASED : events of both types are returned.

Example :

    C++ : TCOD_key_t key = TCODConsole::checkForKeypress();
          if ( key.vk == TCODK_NONE ) return; // no key pressed
          if ( key.c == 'i' ) { ... open inventory ... }
    C   : TCOD_key_t key = TCOD_console_check_for_keypress(TCOD_KEY_PRESSED);
          if ( key.vk == TCODK_NONE ) return; /* no key pressed */
          if ( key.c == 'i' ) { ... open inventory ... }
    Py  : key = libtcod.console_check_for_keypress()
          if key.vk == libtcod.KEY_NONE return # no key pressed
          if key.c == ord('i') : # ... open inventory ...

You can also get the status of any special key at any time with :

    C++ : static bool TCODConsole::isKeyPressed(TCOD_keycode_t key)
    C   : bool TCOD_console_is_key_pressed(TCOD_keycode_t key)
    Py  : console_is_key_pressed(key)

Parameter | Description
--- | ---
key | Any key code defined in keycode_t except TCODK_CHAR and TCODK_NONE.