Skip to content

fix: use event.code instead of event.key for keyboard shortcuts#3748

Open
xob0t wants to merge 1 commit intoDokploy:canaryfrom
xob0t:fix/keyboard-shortcuts-non-english-layouts
Open

fix: use event.code instead of event.key for keyboard shortcuts#3748
xob0t wants to merge 1 commit intoDokploy:canaryfrom
xob0t:fix/keyboard-shortcuts-non-english-layouts

Conversation

@xob0t
Copy link

@xob0t xob0t commented Feb 18, 2026

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.key to detect key presses, which returns characters based on the current keyboard layout. For example:

  • On a Russian layout, pressing the physical "S" key returns "ы" instead of "s"
  • On French AZERTY, pressing the physical "Q" key returns "a"

This means e.key === "s" will never match when a non-English layout is active.

Solution

Replace event.key with event.code for modifier-based shortcuts. event.code returns the physical key location (e.g., KeyS, KeyB) regardless of the active keyboard layout.

Changes

Shortcut Files Changed
Ctrl+B sidebar.tsx
Ctrl+J search-command.tsx
Ctrl+K focus-shortcut-input.tsx
Ctrl+S edit-traefik-env.tsx, project-environment.tsx, environment-variables.tsx, compose-file-editor.tsx, show-enviroment.tsx, show.tsx

Testing

  1. Switch keyboard layout to non-English (e.g., Russian, French AZERTY, German QWERTZ)
  2. Test each shortcut:
    • Ctrl+B: Toggle sidebar
    • Ctrl+J: Open search command dialog
    • Ctrl+S: Save in environment editors
  3. Verify shortcuts work with both English and non-English layouts

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.key to event.code. The event.key property returns layout-dependent characters (e.g., "ы" on Russian layout, "a" on French AZERTY), while event.code returns physical key positions (e.g., KeyS, KeyB) regardless of layout.

Changes applied:

  • Ctrl+S (save): Updated 6 environment editor components to use e.code === "KeyS"
  • Ctrl+B (toggle sidebar): Updated sidebar constant and handler to use "KeyB"
  • Ctrl+J (open search): Updated search command to use e.code === "KeyJ"
  • Ctrl+K (focus input): Updated focus shortcut to use e.code !== "KeyK"

All remaining uses of e.key are for Enter key detection, which is correct since Enter should remain layout-independent.

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • The change is a simple, well-targeted fix that correctly addresses the keyboard layout issue. All changes are consistent (replacing event.key with event.code for modifier-based shortcuts), the implementation is correct (using proper KeyCode format like KeyS, KeyB, KeyJ, KeyK), and there are no side effects. The PR properly preserves all other uses of event.key for Enter key detection, which should remain layout-dependent.
  • No files require special attention

Last reviewed commit: 1926417

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

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
@xob0t xob0t requested a review from Siumauricio as a code owner February 18, 2026 22:52
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard shortcuts don't work with non-English keyboard layouts

1 participant

Comments