modifiersPressed property Null safety
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.
Implementation
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;
}