8000 Show command shortcuts as typed on Dvorak - QWERTY layouts by monsterlag · Pull Request #359 · keycastr/keycastr · GitHub
[go: up one dir, main page]

Skip to content

Show command shortcuts as typed on Dvorak - QWERTY layouts - #359

Open
monsterlag wants to merge 1 commit into
keycastr:mainfrom
monsterlag:fix/issue-117-203a
Open

monsterlag wants to merge 1 commit into
keycastr:mainfrom
monsterlag:fix/issue-117-203a

Conversation

@monsterlag
Copy link
Copy Markdown

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 to UCKeyTranslate when ⌘ 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 pass MACOSX_DEPLOYMENT_TARGET=12.0 because Xcode 27 rejects the project's 10.13 target: From Xcode, the new test runs like the existing ones: KCKeystrokeConversionTests in the KCVisualizerTests target.

  • Added test_dvorakQwertyCommand_commandShortcutsUseQwertyKeycaps to KCKeystrokeConversionTests. It loads the com.apple.keylayout.DVORAK-QWERTYCMD input source and checks that keyCode 8 shows j with no modifiers, and ⌘C (keycap C) with ⌘ held.
  • xcodebuild test -scheme <local KCVisualizerTests scheme> -destination platform=macOS MACOSX_DEPLOYMENT_TARGET=12.0 before 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 in KCEventTransformer.m.

I did not test with a running app and a real Dvorak keyboard.

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.

Breaks dvorak with qwerty commands layout

1 participant

0