isMatch method

bool isMatch(
  1. List<LogicalKeyboardKey> keysPressed,
  2. bool ctrl,
  3. bool alt,
  4. bool shift,
)

Implementation

bool isMatch(
    List<LogicalKeyboardKey> keysPressed, bool ctrl, bool alt, bool shift) {
  // key set sizes don't match
  if (keySequence.isEmpty || keySequence.length != keysPressed.length) {
    return false;
  }

  // control keys don't match
  if ((ctrlPressed && !ctrl) ||
      (altPressed && !alt) ||
      (shiftPressed && !shift)) return false;

  // evaluate keys
  int i = 0;
  bool matchFound = false;
  for (var key in keysPressed) {
    matchFound = (key == keySequence[i] ||
        key.synonyms.contains(keySequence[i]) ||
        keySequence[i].synonyms.contains(key));
    if (matchFound) break;
    i++;
  }

  // return result
  return matchFound;
}