Return the characters that have been typed but not yet processed.
(self)
| 522 | raise WinError(get_last_error()) |
| 523 | |
| 524 | def getpending(self) -> Event: |
| 525 | """Return the characters that have been typed but not yet |
| 526 | processed.""" |
| 527 | e = Event("key", "", b"") |
| 528 | |
| 529 | while not self.event_queue.empty(): |
| 530 | e2 = self.event_queue.get() |
| 531 | if e2: |
| 532 | e.data += e2.data |
| 533 | |
| 534 | recs, rec_count = self._read_input_bulk(1024) |
| 535 | for i in range(rec_count): |
| 536 | rec = recs[i] |
| 537 | # In case of a legacy console, we do not only receive a keydown |
| 538 | # event, but also a keyup event - and for uppercase letters |
| 539 | # an additional SHIFT_PRESSED event. |
| 540 | if rec and rec.EventType == KEY_EVENT: |
| 541 | key_event = rec.Event.KeyEvent |
| 542 | if not key_event.bKeyDown: |
| 543 | continue |
| 544 | ch = key_event.uChar.UnicodeChar |
| 545 | if ch == "\x00": |
| 546 | # ignore SHIFT_PRESSED and special keys |
| 547 | continue |
| 548 | if ch == "\r": |
| 549 | ch += "\n" |
| 550 | e.data += ch |
| 551 | return e |
| 552 | |
| 553 | def wait_for_event(self, timeout: float | None) -> bool: |
| 554 | """Wait for an event.""" |
nothing calls this directly
no test coverage detected