mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 05:50:35 +00:00
Fixes the problems found after #12326 and listed in #12327. Mousetrap now tries several names for each key press, in order, and fires the first one with a binding: letters and digits by keyCode when a modifier is held, punctuation by position (layout map, or a US table when the browser has none), the typed glyph, and the typed glyph without the Shift it needed. With AltGr the typed glyph comes before the position. The shortcut recorder asks Mousetrap for the key it stores, so a recorded shortcut always fires. This makes "?" and "+" work on every layout, Shift and Ctrl+Shift with punctuation work in Firefox and Safari, Option+letter work on macOS, and AltGr+º hide the UI on Linux with a Spanish layout. Chrome on Linux returns the map of the first configured layout, not the active one. Mousetrap now drops the map when an unmodified punctuation key types something else. The layout twins are no longer needed and are removed: "shift+'" made "?" zoom to the selection on Spanish layouts. The Add node shortcut is removed too: on US layouts its key is the "+" zoom key, and on Firefox with a Spanish layout it cannot fire. The Firefox and Safari warning in the shortcuts settings is gone, since those shortcuts now work there. The user guide and translations follow these changes. AI-assisted-by: claude-opus-5-5
@penpot/mousetrap
Vendored keyboard-shortcut library (based on Mousetrap 1.6.5), migrated
from code/keyCode to event.key with lowercase canonical tokens so
shortcuts behave the same across keyboard layouts.
Tests
Unit suite with the Node standard runner, no browser and no extra dependencies:
pnpm test # node --test "test/*.test.js"
The suite builds real Mousetrap instances over fake targets and
synthetic events, with fake timers for sequences. It runs in the frontend
CI through frontend/scripts/test and must stay deterministic (no
network, no real time, no platform reads).