From cd36bd39081c328a8fbd8960ee0744a68f084c88 Mon Sep 17 00:00:00 2001 From: itsnotmeman Date: Tue, 11 Mar 2025 10:04:45 +0100 Subject: [PATCH] branch develop v2: Added a new HardwareKeyboard instance which ignores the numLock key so that shortcuts and arrows always work in the PlutoGrid on Linux. --- lib/src/manager/shortcut/pluto_grid_shortcut.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/manager/shortcut/pluto_grid_shortcut.dart b/lib/src/manager/shortcut/pluto_grid_shortcut.dart index e926e34a2..6872a800b 100644 --- a/lib/src/manager/shortcut/pluto_grid_shortcut.dart +++ b/lib/src/manager/shortcut/pluto_grid_shortcut.dart @@ -29,8 +29,18 @@ class PlutoGridShortcut { required PlutoGridStateManager stateManager, required HardwareKeyboard state, }) { + // Remove NumLock before checking shortcuts. This will enable the arrow + // keys and shortcuts to work correctly on Linux too. + final Set filteredKeys = state.logicalKeysPressed + .where((key) => key != LogicalKeyboardKey.numLock) + .toSet(); + // Create a fake state object with filtered keys. + final HardwareKeyboard fakeState = HardwareKeyboard.instance; + fakeState.logicalKeysPressed.clear(); + fakeState.logicalKeysPressed.addAll(filteredKeys); + for (final action in actions.entries) { - if (action.key.accepts(keyEvent.event, state)) { + if (action.key.accepts(keyEvent.event, fakeState)) { action.value.execute(keyEvent: keyEvent, stateManager: stateManager); return true; }