isModifierPressed method

  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);
  return switch (key) {
    ModifierKey.controlModifier  => modifiers & modifierControl != 0,
    ModifierKey.shiftModifier    => modifiers & modifierShift != 0,
    ModifierKey.altModifier      => modifiers & modifierAlt != 0,
    ModifierKey.metaModifier     => modifiers & modifierMeta != 0,
    ModifierKey.capsLockModifier => modifiers & modifierCapsLock != 0,
    ModifierKey.numLockModifier  => modifiers & modifierNumericPad != 0,
    // These are not used in GLFW keyboards.
    ModifierKey.functionModifier   => false,
    ModifierKey.symbolModifier     => false,
    ModifierKey.scrollLockModifier => false,
  };
}