def pymux_key_to_prompt_toolkit_key_sequence(key):
    """
    Turn a pymux description of a key. E.g.  "C-a" or "M-x" into a
    prompt-toolkit key sequence.

    Raises `ValueError` if the key is not known.
    """
    # Make the c- and m- prefixes case insensitive.
    if key.lower().startswith('m-c-'):
        key = 'M-C-' + key[4:]
    elif key.lower().startswith('c-'):
        key = 'C-' + key[2:]
    elif key.lower().startswith('m-'):
        key = 'M-' + key[2:]

    # Lookup key.
    try:
        return PYMUX_TO_PROMPT_TOOLKIT_KEYS[key]
    except KeyError:
        if len(key) == 1:
            return (key, )
        else:
            raise ValueError('Unknown key: %r' % (key, ))


# Create a mapping from prompt_toolkit keys to their ANSI sequences.
# TODO: This is not completely correct yet. It doesn't take
#       cursor/application mode into account. Create new tables for this.
dataset/ETHPy150Open jonathanslenders/pymux/pymux/key_mappings.py/pymux_key_to_prompt_toolkit_key_sequence/original