modifiersPressed property

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.


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) {
            '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;