waitForKeyWithResult method

KeyActionResult waitForKeyWithResult()

Waits for a key and returns whichever KeyActionResult resolves first.

Keeps looping until a binding returns something other than KeyActionResult.ignored, which makes it ideal for command-line tools that just need to block until the user acknowledges something.

Implementation

KeyActionResult waitForKeyWithResult() {
  while (true) {
    final event = KeyEventReader.read();
    final result = handle(event);
    if (result != KeyActionResult.ignored) {
      return result;
    }
  }
}