firstMatch method

KeyBinding? firstMatch(
  1. KeyMsg msg
)

Returns the first enabled KeyBinding that matches msg, or null.

Useful when you need to dispatch stateful actions in update() based on which binding matched:

final binding = keyMap.firstMatch(msg);
if (binding == keyMap.up) { _cursorUp(); }
else if (binding == keyMap.down) { _cursorDown(); }

Implementation

KeyBinding? firstMatch(KeyMsg msg) {
  for (final binding in shortHelp) {
    if (binding.matches(msg)) return binding;
  }
  return null;
}