Skip to content

Conversation

@mikker
Copy link
Owner

@mikker mikker commented Sep 22, 2025

Fixes #255 #264

Problem

The keyboard layout regression introduced in v1.17.0 broke support for non-QWERTY layouts (AZERTY, Colemak, Dvorak, etc.). The new KeyMaps system was always using hardcoded US-QWERTY mapping, ignoring the user's actual keyboard layout.

Root Cause

  • Controller.charForEvent() unconditionally used KeyMaps lookup instead of respecting event.charactersIgnoringModifiers
  • The "Force English keyboard layout" setting existed but was effectively always enabled
  • Physical keys were interpreted as QWERTY positions rather than the logical characters they produce

Solution

  • Respect user's layout by default: Use event.charactersIgnoringModifiers for printable characters
  • Honor the force English preference: Only use KeyMaps when explicitly enabled
  • Preserve special keys: Non-printable keys (arrows, escape, etc.) still use lookup table
  • Maintain case sensitivity: Both "r" and "R" can trigger different actions

Changes

  • Fixed charForEvent() method to branch on forceEnglishKeyboardLayout setting
  • Added helper englishGlyph() method for force English mode
  • Enhanced preferences UI with explanatory help text
  • Added comprehensive unit tests covering both layout modes and case sensitivity

Testing

  • ✅ All existing tests pass (no regressions)
  • ✅ 7 new unit tests validate keyboard layout handling
  • ✅ Tests cover AZERTY, Colemak, case sensitivity, and special keys
  • ✅ Both force English modes tested

Impact

  • AZERTY users: Physical "A" key now correctly produces "q" instead of "a"
  • Colemak users: All letter keys now respect layout instead of QWERTY positions
  • All users: "Force English keyboard layout" preference now works as intended
  • Backward compatibility: Existing behavior preserved when force English is enabled

Fixes #255 #264

- Restore support for AZERTY, Colemak, Dvorak and other keyboard layouts
- The 'Force English keyboard layout' preference now works correctly
- By default, respects user's active keyboard layout via event.charactersIgnoringModifiers
- When force English is enabled, uses hardcoded QWERTY KeyMaps as before
- Special keys (arrows, escape, etc.) always use KeyMaps regardless of setting
- Maintains case sensitivity (r ≠ R) in both modes
- Add comprehensive unit tests for keyboard layout handling
- Add help text to preferences explaining the force English option

This fixes a regression introduced in v1.17.0 where the new KeyMaps system
always used QWERTY mapping, breaking non-QWERTY keyboard layouts.

Amp-Thread-ID: https://ampcode.com/threads/T-2db41565-b3b2-4f93-80ce-9345163be879
Co-authored-by: Amp <amp@ampcode.com>
@mikker mikker merged commit 9c53f8d into main Sep 22, 2025
2 checks passed
@mikker mikker deleted the fix/keyboard-layout-regression branch September 22, 2025 20:37
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.

No longer recognizing "AZERTY" layout. Keyboard Input issue.

2 participants