Repository navigation
Show command shortcuts as typed on Dvorak - QWERTY layouts - #359
Open
monsterlag wants to merge 1 commit into
Open
monsterlag wants to merge 1 commit into
monsterlag wants to merge 1 commit into
Conversation
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.
Note
AI-generated, not reviewed by a human. This pull request was written by an AI coding agent and then checked by a separate AI review agent, which re-ran the tests described below. No human has reviewed the code. It is submitted by @monsterlag, who runs these agents. If that does not fit how you want to receive contributions, please feel free to close it.
What
With the "Dvorak - QWERTY ⌘" input source, macOS switches the keyboard to QWERTY while ⌘ is held, so the key labelled J in Dvorak (QWERTY C, keyCode 8) triggers ⌘C (Copy). KeyCastr translated every key code with no modifier state, so it showed that shortcut as ⌘J. Same for ⌘V, ⌘X and the rest.
Fixes #117
How
-translatedCharacterForKeystroke:now passes the command modifier toUCKeyTranslatewhen ⌘ is down, so the layout's own command key map is used, which is the map macOS uses to match the shortcut. If that map has no character for the key, it falls back to the unmodified translation, as before. Only ⌘ is passed (not ⌃, ⌥ or ⇧), so the existing keycap and uppercasing rules are unchanged.Effect on other layouts: I compared each installed layout's base map with its command map in a macOS 26.6 VM. US, ABC, German, French, plain Dvorak and the other Latin layouts I checked have the same characters with and without ⌘, so their output does not change. Layouts with non-Latin scripts (Russian, Greek, Hebrew, Arabic and others) map ⌘ to Latin letters. On those layouts ⌘C on the key labelled С now shows ⌘C, which matches what macOS shows in its menus. Please say if you would rather limit the change. This also matches what was asked for in #242 (Latin command letters on a Japanese Kana layout); happy to limit it to Latin-script layouts if you prefer.
How tested
On macOS 26.6 / Xcode 27.1, with submodules initialised. The project has no shared scheme that runs
KCVisualizerTests, so I made a local, uncommitted scheme for that target. I also had to passMACOSX_DEPLOYMENT_TARGET=12.0because Xcode 27 rejects the project's 10.13 target: From Xcode, the new test runs like the existing ones:KCKeystrokeConversionTestsin theKCVisualizerTeststarget.test_dvorakQwertyCommand_commandShortcutsUseQwertyKeycapstoKCKeystrokeConversionTests. It loads thecom.apple.keylayout.DVORAK-QWERTYCMDinput source and checks that keyCode 8 showsjwith no modifiers, and⌘C(keycapC) with ⌘ held.xcodebuild test -scheme <local KCVisualizerTests scheme> -destination platform=macOS MACOSX_DEPLOYMENT_TARGET=12.0before the fix: the new test failed with("⌘J") is not equal to ("⌘C")and("J") is not equal to ("C"). After the fix:Executed 39 tests, with 0 failures,** TEST SUCCEEDED **.xcodebuild build -scheme KeyCastr -destination platform=macOS MACOSX_DEPLOYMENT_TARGET=12.0 CODE_SIGNING_ALLOWED=NO(signing disabled, since the project's team certificate is not available):** BUILD SUCCEEDED **, with no new warnings inKCEventTransformer.m.I did not test with a running app and a real Dvorak keyboard.