fix: use event.code instead of event.key for keyboard shortcuts#3748
Open
xob0t wants to merge 1 commit intoDokploy:canaryfrom
Open
fix: use event.code instead of event.key for keyboard shortcuts#3748xob0t wants to merge 1 commit intoDokploy:canaryfrom
xob0t wants to merge 1 commit intoDokploy:canaryfrom
Conversation
This fixes keyboard shortcuts (Ctrl+S, Ctrl+B, Ctrl+J, Ctrl+K) not working with non-English keyboard layouts (e.g., Russian, French AZERTY, German QWERTZ). Fixes Dokploy#3495
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.
Summary
This PR fixes keyboard shortcuts (Ctrl+S, Ctrl+B, Ctrl+J, Ctrl+K) not working with non-English keyboard layouts (e.g., Russian, French AZERTY, German QWERTZ).
Problem
The current implementation uses
event.keyto detect key presses, which returns characters based on the current keyboard layout. For example:This means
e.key === "s"will never match when a non-English layout is active.Solution
Replace
event.keywithevent.codefor modifier-based shortcuts.event.codereturns the physical key location (e.g.,KeyS,KeyB) regardless of the active keyboard layout.Changes
sidebar.tsxsearch-command.tsxfocus-shortcut-input.tsxedit-traefik-env.tsx,project-environment.tsx,environment-variables.tsx,compose-file-editor.tsx,show-enviroment.tsx,show.tsxTesting
Fixes #3495
Greptile Summary
Fixed keyboard shortcuts (Ctrl+B, Ctrl+J, Ctrl+K, Ctrl+S) to work with non-English keyboard layouts by switching from
event.keytoevent.code. Theevent.keyproperty returns layout-dependent characters (e.g., "ы" on Russian layout, "a" on French AZERTY), whileevent.codereturns physical key positions (e.g.,KeyS,KeyB) regardless of layout.Changes applied:
e.code === "KeyS""KeyB"e.code === "KeyJ"e.code !== "KeyK"All remaining uses of
e.keyare for Enter key detection, which is correct since Enter should remain layout-independent.Confidence Score: 5/5
event.keywithevent.codefor modifier-based shortcuts), the implementation is correct (using proper KeyCode format likeKeyS,KeyB,KeyJ,KeyK), and there are no side effects. The PR properly preserves all other uses ofevent.keyfor Enter key detection, which should remain layout-dependent.Last reviewed commit: 1926417
(2/5) Greptile learns from your feedback when you react with thumbs up/down!