libtcod / python-tcod

A high-performance Python port of libtcod. Includes the libtcodpy module for backwards compatibility with older projects.
BSD 2-Clause "Simplified" License
410 stars 36 forks source link

Documentation: possible values for KeyboardEvent.sym are not documented #86

Closed mgedmin closed 4 years ago

mgedmin commented 4 years ago

I see no mention in https://python-tcod.readthedocs.io/en/latest/tcod/event.html of the keysym constants available from tcod.event:

>>> import tcod.event
>>> [name for name in dir(tcod.event) if name.startswith('K_')]
['K_0', 'K_1', 'K_2', 'K_3', 'K_4', 'K_5', 'K_6', 'K_7', 'K_8', 'K_9', 'K_AC_BACK', 'K_AC_BOOKMARKS', 'K_AC_FORWARD', 'K_AC_HOME', 'K_AC_REFRESH', 'K_AC_SEARCH', 'K_AC_STOP', 'K_AGAIN', 'K_ALTERASE', 'K_AMPERSAND', 'K_APPLICATION', 'K_ASTERISK', 'K_AT', 'K_AUDIOMUTE', 'K_AUDIONEXT', 'K_AUDIOPLAY', 'K_AUDIOPREV', 'K_AUDIOSTOP', 'K_BACKQUOTE', 'K_BACKSLASH', 'K_BACKSPACE', 'K_BRIGHTNESSDOWN', 'K_BRIGHTNESSUP', 'K_CALCULATOR', 'K_CANCEL', 'K_CAPSLOCK', 'K_CARET', 'K_CLEAR', 'K_CLEARAGAIN', 'K_COLON', 'K_COMMA', 'K_COMPUTER', 'K_COPY', 'K_CRSEL', 'K_CURRENCYSUBUNIT', 'K_CURRENCYUNIT', 'K_CUT', 'K_DECIMALSEPARATOR', 'K_DELETE', 'K_DISPLAYSWITCH', 'K_DOLLAR', 'K_DOWN', 'K_EJECT', 'K_END', 'K_EQUALS', 'K_ESCAPE', 'K_EXCLAIM', 'K_EXECUTE', 'K_EXSEL', 'K_F1', 'K_F10', 'K_F11', 'K_F12', 'K_F13', 'K_F14', 'K_F15', 'K_F16', 'K_F17', 'K_F18', 'K_F19', 'K_F2', 'K_F20', 'K_F21', 'K_F22', 'K_F23', 'K_F24', 'K_F3', 'K_F4', 'K_F5', 'K_F6', 'K_F7', 'K_F8', 'K_F9', 'K_FIND', 'K_GREATER', 'K_HASH', 'K_HELP', 'K_HOME', 'K_INSERT', 'K_KBDILLUMDOWN', 'K_KBDILLUMTOGGLE', 'K_KBDILLUMUP', 'K_KP_0', 'K_KP_00', 'K_KP_000', 'K_KP_1', 'K_KP_2', 'K_KP_3', 'K_KP_4', 'K_KP_5', 'K_KP_6', 'K_KP_7', 'K_KP_8', 'K_KP_9', 'K_KP_A', 'K_KP_AMPERSAND', 'K_KP_AT', 'K_KP_B', 'K_KP_BACKSPACE', 'K_KP_BINARY', 'K_KP_C', 'K_KP_CLEAR', 'K_KP_CLEARENTRY', 'K_KP_COLON', 'K_KP_COMMA', 'K_KP_D', 'K_KP_DBLAMPERSAND', 'K_KP_DBLVERTICALBAR', 'K_KP_DECIMAL', 'K_KP_DIVIDE', 'K_KP_E', 'K_KP_ENTER', 'K_KP_EQUALS', 'K_KP_EQUALSAS400', 'K_KP_EXCLAM', 'K_KP_F', 'K_KP_GREATER', 'K_KP_HASH', 'K_KP_HEXADECIMAL', 'K_KP_LEFTBRACE', 'K_KP_LEFTPAREN', 'K_KP_LESS', 'K_KP_MEMADD', 'K_KP_MEMCLEAR', 'K_KP_MEMDIVIDE', 'K_KP_MEMMULTIPLY', 'K_KP_MEMRECALL', 'K_KP_MEMSTORE', 'K_KP_MEMSUBTRACT', 'K_KP_MINUS', 'K_KP_MULTIPLY', 'K_KP_OCTAL', 'K_KP_PERCENT', 'K_KP_PERIOD', 'K_KP_PLUS', 'K_KP_PLUSMINUS', 'K_KP_POWER', 'K_KP_RIGHTBRACE', 'K_KP_RIGHTPAREN', 'K_KP_SPACE', 'K_KP_TAB', 'K_KP_VERTICALBAR', 'K_KP_XOR', 'K_LALT', 'K_LCTRL', 'K_LEFT', 'K_LEFTBRACKET', 'K_LEFTPAREN', 'K_LESS', 'K_LGUI', 'K_LSHIFT', 'K_MAIL', 'K_MEDIASELECT', 'K_MENU', 'K_MINUS', 'K_MODE', 'K_MUTE', 'K_NUMLOCKCLEAR', 'K_OPER', 'K_OUT', 'K_PAGEDOWN', 'K_PAGEUP', 'K_PASTE', 'K_PAUSE', 'K_PERCENT', 'K_PERIOD', 'K_PLUS', 'K_POWER', 'K_PRINTSCREEN', 'K_PRIOR', 'K_QUESTION', 'K_QUOTE', 'K_QUOTEDBL', 'K_RALT', 'K_RCTRL', 'K_RETURN', 'K_RETURN2', 'K_RGUI', 'K_RIGHT', 'K_RIGHTBRACKET', 'K_RIGHTPAREN', 'K_RSHIFT', 'K_SCANCODE_MASK', 'K_SCROLLLOCK', 'K_SELECT', 'K_SEMICOLON', 'K_SEPARATOR', 'K_SLASH', 'K_SLEEP', 'K_SPACE', 'K_STOP', 'K_SYSREQ', 'K_TAB', 'K_THOUSANDSSEPARATOR', 'K_UNDERSCORE', 'K_UNDO', 'K_UNKNOWN', 'K_UP', 'K_VOLUMEDOWN', 'K_VOLUMEUP', 'K_WWW', 'K_a', 'K_b', 'K_c', 'K_d', 'K_e', 'K_f', 'K_g', 'K_h', 'K_i', 'K_j', 'K_k', 'K_l', 'K_m', 'K_n', 'K_o', 'K_p', 'K_q', 'K_r', 'K_s', 'K_t', 'K_u', 'K_v', 'K_w', 'K_x', 'K_y', 'K_z']

This makes it a bit difficult to write code using tcod.event.

HexDecimal commented 4 years ago

The constants are derived directly from SDL, so you can find a detailed list of them here: https://wiki.libsdl.org/SDL_Keycode. Remove the SDL prefix to get the tcod.event constant name.

Maybe it'd be better if the SDL prefixes were included and I just linked to that page. Do you have any ideas?

mgedmin commented 4 years ago

A link with some accompanying text and a small example would be sufficient, I think.

I don't think tcod needs to use SDL prefixes, tcod.event.K_... is already a long-enough fully qualified name (and I hate from X import * for taking away flake8's ability to warn me about misspelled names, so I won't use it.)