< index < 2. Console emulator < 2.3 Handling keyboard input |
===================================== |
C++ : static TCOD_key_t TCODConsole::checkForKeypress(int flags=TCOD_KEY_PRESSED) C : TCOD_key_t TCOD_console_check_for_keypress(int flags) Py : console_check_for_keypress(flags=KEY_PRESSED)
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. |
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 ...
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. |