isModifierPressed method Null safety

  1. @override
bool isModifierPressed(
  1. ModifierKey key,
  2. int modifiers,
  3. {KeyboardSide side = KeyboardSide.any,
  4. required int keyCode,
  5. required bool isDown}
)
override

Returns true if the given ModifierKey was pressed at the time of this event.

Implementation

@override
bool isModifierPressed(ModifierKey key, int modifiers, {KeyboardSide side = KeyboardSide.any, required int keyCode, required bool isDown}) {
  modifiers = _mergeModifiers(modifiers: modifiers, keyCode: keyCode, isDown: isDown);
  switch (key) {
    case ModifierKey.controlModifier:
      return modifiers & modifierControl != 0;
    case ModifierKey.shiftModifier:
      return modifiers & modifierShift != 0;
    case ModifierKey.altModifier:
      return modifiers & modifierMod1 != 0;
    case ModifierKey.metaModifier:
      return modifiers & modifierMeta != 0;
    case ModifierKey.capsLockModifier:
      return modifiers & modifierCapsLock != 0;
    case ModifierKey.numLockModifier:
      return modifiers & modifierMod2 != 0;
    case ModifierKey.functionModifier:
    case ModifierKey.symbolModifier:
    case ModifierKey.scrollLockModifier:
      // These are not used in GTK keyboards.
      return false;
  }
}