flush method

List<KeyEvent> flush()

Flushes any buffered bytes as a best-effort final decode (e.g. a lone trailing ESC). Call when input ends, or when hasPendingEscape has stayed set for escapeTimeout.

Implementation

List<KeyEvent> flush() {
  final events = <KeyEvent>[];
  if (_pending.length == 1 && _pending.first == 0x1b) {
    events.add(const KeyEvent(KeyType.escape));
    _pending.clear();
  }
  return events;
}