def _parseKeyNames(lib):
    """
    returns a dictionary mapping of human readable key names to their keycodes
    this parses constants with the names of K_* and makes code=name pairs
    this is for KeyEvent.key variable and that enables things like:
    if (event.key == 'PAGEUP'):
    """
    _keyNames = {}
    for attr in dir(lib):
        if attr[:6] == 'TCODK_':
            _keyNames[getattr(lib, attr)] = attr[6:]
    return _keyNames
