isModifierPressed method Null safety

  1. @override
bool isModifierPressed(
  1. ModifierKey key,
  2. {KeyboardSide side = KeyboardSide.any}
)
override

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

If side is specified, then this restricts its check to the specified side of the keyboard. Defaults to checking for the key being down on either side of the keyboard. If there is only one instance of the key on the keyboard, then side is ignored.

Implementation

@override
bool isModifierPressed(ModifierKey key, { KeyboardSide side = KeyboardSide.any }) {
  assert(side != null);
  switch (key) {
    case ModifierKey.controlModifier:
      return _isLeftRightModifierPressed(side, modifierControl, modifierLeftControl, modifierRightControl);
    case ModifierKey.shiftModifier:
      return _isLeftRightModifierPressed(side, modifierShift, modifierLeftShift, modifierRightShift);
    case ModifierKey.altModifier:
      return _isLeftRightModifierPressed(side, modifierAlt, modifierLeftAlt, modifierRightAlt);
    case ModifierKey.metaModifier:
      return _isLeftRightModifierPressed(side, modifierMeta, modifierLeftMeta, modifierRightMeta);
    case ModifierKey.capsLockModifier:
      return modifiers & modifierCapsLock != 0;
    case ModifierKey.numLockModifier:
    case ModifierKey.scrollLockModifier:
    case ModifierKey.functionModifier:
    case ModifierKey.symbolModifier:
      // Fuchsia doesn't have masks for these keys (yet).
      return false;
  }
}