modifiersPressed property

  1. @Deprecated('No longer available. Inspect HardwareKeyboard.instance.logicalKeysPressed instead. ' 'This feature was deprecated after v3.18.0-2.0.pre.')
Map<ModifierKey, KeyboardSide> modifiersPressed

Returns a map of modifier keys that were pressed at the time of this event, and the keyboard side or sides that the key was on.

This method is deprecated and will be removed. For equivalent information, inspect HardwareKeyboard.logicalKeysPressed instead.

Implementation

@Deprecated(
  'No longer available. Inspect HardwareKeyboard.instance.logicalKeysPressed instead. '
  'This feature was deprecated after v3.18.0-2.0.pre.',
)
Map<ModifierKey, KeyboardSide> get modifiersPressed {
  final Map<ModifierKey, KeyboardSide> result = <ModifierKey, KeyboardSide>{};
  for (final ModifierKey key in ModifierKey.values) {
    if (isModifierPressed(key)) {
      final KeyboardSide? side = getModifierSide(key);
      if (side != null) {
        result[key] = side;
      }
      assert(() {
        if (side == null) {
          debugPrint(
            'Raw key data is returning inconsistent information for '
            'pressed modifiers. isModifierPressed returns true for $key '
            'being pressed, but when getModifierSide is called, it says '
            'that no modifiers are pressed.',
          );
          if (this is RawKeyEventDataAndroid) {
            debugPrint('Android raw key metaState: ${(this as RawKeyEventDataAndroid).metaState}');
          }
        }
        return true;
      }());
    }
  }
  return result;
}