intercept method

bool intercept(
  1. KeyMsg msg
)

Returns true if a matching binding's KeyBinding.action was called.

Iterates shortHelp, invokes KeyBinding.action on the first enabled binding that matches msg. Returns true if consumed. Designed for use in widget handleIntercept:

@override
bool handleIntercept(Msg msg) {
  if (msg is KeyMsg && keyMap.intercept(msg)) return true;
  return super.handleIntercept(msg);
}

Implementation

bool intercept(KeyMsg msg) {
  for (final binding in shortHelp) {
    if (!binding.matches(msg)) continue;
    if (binding.action != null) {
      binding.action!();
      return true;
    }
  }
  return false;
}