def _decode_ctrl(key):
    """
    Convert control codes ("\x01" - "\x1A") into ascii representation C-x
    """
    assert len(key) == 1
    if key == '\n':
        return 'RET'
    code = ord(key)
    if not 0 < code <= 0x1A:
        # Not control code
        return key
    letter = code + ord('a') - 1
    return ("C-" + chr(letter)).replace("C-i", "TAB")