

def _event_to_key_presses(self, ev):
    '\n        For this `KEY_EVENT_RECORD`, return a list of `KeyPress` instances.\n        '
    assert ((type(ev) == KEY_EVENT_RECORD) and ev.KeyDown)
    result = None
    u_char = ev.uChar.UnicodeChar
    ascii_char = ev.uChar.AsciiChar
    if (u_char == '\x00'):
        if (ev.VirtualKeyCode in self.keycodes):
            result = KeyPress(self.keycodes[ev.VirtualKeyCode], '')
    elif (ascii_char in self.mappings):
        result = KeyPress(self.mappings[ascii_char], u_char)
    else:
        result = KeyPress(u_char, u_char)
    if (((ev.ControlKeyState & self.LEFT_CTRL_PRESSED) or (ev.ControlKeyState & self.RIGHT_CTRL_PRESSED)) and result):
        if (result.key == Keys.Left):
            result.key = Keys.ControlLeft
        if (result.key == Keys.Right):
            result.key = Keys.ControlRight
        if (result.key == Keys.Up):
            result.key = Keys.ControlUp
        if (result.key == Keys.Down):
            result.key = Keys.ControlDown
    if ((ev.ControlKeyState & self.SHIFT_PRESSED) and result):
        if (result.key == Keys.Tab):
            result.key = Keys.BackTab
    if (((ev.ControlKeyState & self.LEFT_CTRL_PRESSED) or (ev.ControlKeyState & self.RIGHT_CTRL_PRESSED)) and result and (result.data == ' ')):
        result = KeyPress(Keys.ControlSpace, ' ')
    if (((ev.ControlKeyState & self.LEFT_CTRL_PRESSED) or (ev.ControlKeyState & self.RIGHT_CTRL_PRESSED)) and result and (result.key == Keys.ControlJ)):
        return [KeyPress(Keys.Escape, ''), result]
    if result:
        meta_pressed = (ev.ControlKeyState & self.LEFT_ALT_PRESSED)
        if meta_pressed:
            return [KeyPress(Keys.Escape, ''), result]
        else:
            return [result]
    else:
        return []

dataset/ETHPy150Open jonathanslenders/python-prompt-toolkit/prompt_toolkit/terminal/win32_input.py ConsoleInputReader._event_to_key_presses/original