Skip to content

Commit cfeff6b

Browse files
authored
bug fix that multi eventHandler does not fire (#53)
1 parent 7422790 commit cfeff6b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

packages/hotkey_manager/lib/src/hotkey_manager.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,21 @@ class HotKeyManager {
6565

6666
if (keyEvent is KeyDownEvent) {
6767
final physicalKeysPressed = HardwareKeyboard.instance.physicalKeysPressed;
68-
HotKey? hotKey = _hotKeyList.firstWhereOrNull(
69-
(e) {
70-
List<HotKeyModifier> modifiers = HotKeyModifier.values
71-
.where((e) => e.physicalKeys.any(physicalKeysPressed.contains))
72-
.toList();
73-
return e.scope == HotKeyScope.inapp &&
74-
keyEvent.logicalKey == e.logicalKey &&
75-
modifiers.length == (e.modifiers?.length ?? 0) &&
76-
modifiers.every((e.modifiers ?? []).contains);
77-
},
78-
);
79-
if (hotKey != null) {
80-
HotKeyHandler? handler = _keyDownHandlerMap[hotKey.identifier];
81-
if (handler != null) handler(hotKey);
82-
_lastPressedHotKey = hotKey;
68+
final hotKeys = _hotKeyList.where((e) {
69+
List<HotKeyModifier> modifiers = HotKeyModifier.values
70+
.where((e) => e.physicalKeys.any(physicalKeysPressed.contains))
71+
.toList();
72+
return e.scope == HotKeyScope.inapp &&
73+
keyEvent.logicalKey == e.logicalKey &&
74+
modifiers.length == (e.modifiers?.length ?? 0) &&
75+
modifiers.every((e.modifiers ?? []).contains);
76+
});
77+
if (hotKeys.isNotEmpty) {
78+
for (final hotKey in hotKeys) {
79+
HotKeyHandler? handler = _keyDownHandlerMap[hotKey.identifier];
80+
if (handler != null) handler(hotKey);
81+
}
82+
_lastPressedHotKey = hotKeys.last;
8383
return true;
8484
}
8585
}

0 commit comments

Comments
 (0)