def read(self):
        max_count = 1024  # Read max 1024 events at the same time.
        result = []

        read = DWORD(0)

        arrtype = INPUT_RECORD * max_count
        input_records = arrtype()

        # Get next batch of input event.
        windll.kernel32.ReadConsoleInputW(self.handle, pointer(input_records), max_count, pointer(read))

        for i in range(read.value):
            ir = input_records[i]

            # Get the right EventType from the EVENT_RECORD.
            # (For some reason the Windows console application 'cmder'
            # [http://gooseberrycreative.com/cmder/] can return '0' for
            # ir.EventType. -- Just ignore that.)
            if ir.EventType in EventTypes:
                ev = getattr(ir.Event, EventTypes[ir.EventType])

                # Process if this is a key event. (We also have mouse, menu and
                # focus events.)
                if type(ev) == KEY_EVENT_RECORD and ev.KeyDown:
                    key_presses = self._event_to_key_presses(ev)
                    if key_presses:
                        result.extend(key_presses)

                elif type(ev) == MOUSE_EVENT_RECORD:
                    result.extend(self._handle_mouse(ev))

        return result
Read from the Windows console and return a list of `KeyPress` instances.
dataset/ETHPy150Open jonathanslenders/python-prompt-toolkit/prompt_toolkit/terminal/win32_input.py/ConsoleInputReader.read