Vps 16 add keyboards shortcuts to the editor#403
Open
FridgeProtector1 wants to merge 7 commits into
Open
Conversation
It was in the git ignore so I dont know why its still here like its haunting me or smth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
The editor needs shortcut handling to respect OS-specific modifier keys so the same shortcut system works correctly on both Mac and Windows.
Solution
Add a centralized keyboard shortcut handling layer that listens for key events and maps them to existing editor actions. The shortcut logic uses a shared shortcut definition structure to match key combinations against the current platform’s primary modifier key, so Cmd/metaKey is used on Mac and Ctrl is used on Windows. This means Ctrl is not treated as the same shortcut on macOS unless it is explicitly bound that way.
When a shortcut is matched, the handler dispatches to the same existing functions used by the editor UI rather than reimplementing the underlying behavior.
Risk
Not too sure but perhaps there could be conflicts with browser specific shortcuts (Didn't notice anything but idk any browser short cuts anyways).
Shortcuts mapped
On Windows/Linux, mod means Ctrl
On macOS, mod means Cmd
Z index commands don't work too well but I believe they weren't working to begin with, but they are mapped too.
Shortcuts
mod+z → Undo
mod+shift+z → Redo
mod+y → Redo
mod+d → Duplicate selected component
Backspace / Delete → Remove selected component
only when not in text mode
mod+ArrowUp → Bring forward one layer
mod+Shift+ArrowUp → Bring to front
mod+ArrowDown → Send backward one layer
mod+Shift+ArrowDown → Send to back
Text mode shortcuts
mod+a → Select all text
mod+b → Toggle bold
mod+i → Toggle italic
mod+u → Toggle underline
Existing non-shortcut keyboard behavior still kept
Arrow keys move selected components by 5px when not in text mode
In text mode, arrow keys / Home / End / typing / Enter / Backspace still use the existing text editor behavior
Platform note
How to add more
Add new shortcuts in frontend/src/features/authoring/handlers/keyboard/shortcuts.ts by defining a new key combination and mapping it to an existing editor action. keyboard.ts already routes global keydown events through handleShortcut(e), so new bindings only need to be added to the shortcut map and matched with the platform-specific primary modifier.
Checklist