# T2. Input System{twn}

Go back

T2.1 Design

> One of goals is to make system that has the least variance in handling. We combine mouse inputs with keys and don't use keycodes whatsoever. Key combinations are supported. Everything is represented with an encoded string:

>     [control+]+control

> Any variant should be combinable, even things like mouse movement + key press.

> One current limitation of such design is that actions will only be reported in next frame after they were first declared, creating delay. It's possible to fix it in the future however.

T2.2 API

> It's rather small:

>     void input_action(const char *name
>     bool input_action_pressed(const char *name);
>     bool input_action_just_pressed(const char *name);
>     bool input_action_just_released(const char *name);
>     Vec2 input_action_position(const char *name);

> Lists of controls, from src/twn_input.c:

> -- Keyboard --

>     "A"
>     "B"
>     "C"
>     "D"
>     "E"
>     "F"
>     "G"
>     "H"
>     "I"
>     "J"
>     "K"
>     "L"
>     "M"
>     "N"
>     "O"
>     "P"
>     "Q"
>     "R"
>     "S"
>     "T"
>     "U"
>     "V"
>     "W"
>     "X"
>     "Y"
>     "Z"
>     "1"
>     "2"
>     "3"
>     "4"
>     "5"
>     "6"
>     "7"
>     "8"
>     "9"
>     "0"
>     "RETURN"
>     "ENTER" /* an alias */
>     "ESCAPE"
>     "BACKSPACE"
>     "TAB"
>     "SPACE"
>     "MINUS"
>     "EQUALS"
>     "LEFTBRACKET"
>     "RIGHTBRACKET"
>     "BACKSLASH"
>     "NONUSHASH"
>     "SEMICOLON"
>     "APOSTROPHE"
>     "GRAVE"
>     "COMMA"
>     "PERIOD"
>     "SLASH"
>     "CAPSLOCK"
>     "F1"
>     "F2"
>     "F3"
>     "F4"
>     "F5"
>     "F6"
>     "F7"
>     "F8"
>     "F9"
>     "F10"
>     "F11"
>     "F12"
>     "PRINTSCREEN"
>     "SCROLLLOCK"
>     "PAUSE"
>     "INSERT"
>     "HOME"
>     "PAGEUP"
>     "DELETE"
>     "END"
>     "PAGEDOWN"
>     "RIGHT"
>     "LEFT"
>     "DOWN"
>     "UP"
>     "KPDIVIDE"
>     "KPMULTIPLY"
>     "KPMINUS"
>     "KPPLUS"
>     "KPENTER"
>     "KP1"
>     "KP2"
>     "KP3"
>     "KP4"
>     "KP5"
>     "KP6"
>     "KP7"
>     "KP8"
>     "KP9"
>     "KP0"
>     "LCTRL"
>     "LSHIFT"
>     "LALT"
>     "RCTRL"
>     "RSHIFT"

> -- Mouse --

>     "LCLICK"
>     "MCLICK"
>     "RCLICK"