Skip to content

Fix text insertion on Dvorak-QWERTY hybrid keyboard layout#163

Open
darknoon wants to merge 1 commit intokitlangton:mainfrom
darknoon:dvorak-qwerty-insertion
Open

Fix text insertion on Dvorak-QWERTY hybrid keyboard layout#163
darknoon wants to merge 1 commit intokitlangton:mainfrom
darknoon:dvorak-qwerty-insertion

Conversation

@darknoon
Copy link
Copy Markdown

@darknoon darknoon commented Jan 29, 2026

Summary

Fixes #162 - Text insertion was broken on the "Dvorak — QWERTY ⌘" keyboard layout.

The Cmd+V paste operation was using Sauce.shared.keyCode(for: .v) which returns the layout's V key position. On hybrid layouts like "Dvorak — QWERTY ⌘", this returned the Dvorak V position, but when Command is held, the layout switches to QWERTY positions—causing a mismatch and error beep.

Fix: Added detection for hybrid layouts that use QWERTY positions for Command shortcuts. For these layouts, we use the hardcoded QWERTY V key code (9). All other layouts continue using Sauce's layout-aware key code.

Test plan

  • Test with "Dvorak — QWERTY ⌘" layout: transcription should paste correctly
  • Test with regular Dvorak layout: transcription should still paste correctly
  • Test with QWERTY layout: no regression

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed text insertion on Dvorak–QWERTY hybrid keyboard layouts.
    • Improved paste (Cmd+V) handling so paste operations respect the active keyboard layout.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

Adds layout-aware Cmd+V handling to ensure the correct V key code is used on hybrid keyboard layouts (e.g., Dvorak — QWERTY ⌘) so paste-based text insertion works across different input configurations.

Changes

Cohort / File(s) Summary
Release documentation
.changeset/2910283a.md
Adds a patch-level changeset entry noting a fix for text insertion on Dvorak–QWERTY hybrid keyboard layouts.
Keyboard layout awareness
Hex/Clients/PasteboardClient.swift
Adds vKeyCode() and usesQWERTYShortcuts() logic and imports Carbon to detect hybrid layouts and choose the correct V key code; postCmdV() now uses the layout-aware key selection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I hopped to keys both old and new,
Found V where QWERTY hid from view.
I nudged the paste to land just right,
Now hybrids type without a fright.
Hooray — the text hops home tonight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing text insertion on Dvorak-QWERTY hybrid keyboard layouts, matching the primary objective.
Linked Issues check ✅ Passed The changes successfully address issue #162 by detecting hybrid layouts and using QWERTY V key positions for Cmd+V operations instead of layout-specific positions.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the keyboard layout issue: layout detection, V key handling, and paste operation fixes with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@Hex/Clients/PasteboardClient.swift`:
- Around line 333-345: Update the comment above the usesQWERTYShortcuts() method
to append the GitHub issue reference in the mandated format; modify the
hybrid-layout comment that currently reads "Hybrid layouts that switch to QWERTY
when Command is held" by adding the issue number in parentheses (e.g. (`#123`)) so
the comment references the filed issue per guidelines.
🧹 Nitpick comments (1)
Hex/Clients/PasteboardClient.swift (1)

322-331: Prefer the named constant for V’s key code (avoid magic number).
Use kVK_ANSI_V for clarity and to leverage the Carbon import.

♻️ Suggested change
-        if usesQWERTYShortcuts() {
-            return 9  // kVK_ANSI_V (QWERTY V position)
-        }
+        if usesQWERTYShortcuts() {
+            return CGKeyCode(kVK_ANSI_V)
+        }
         return Sauce.shared.keyCode(for: .v)

Comment thread Hex/Clients/PasteboardClient.swift
The Cmd+V paste operation was using Sauce.shared.keyCode(for: .v) which
returns the layout's V key position. On "Dvorak — QWERTY ⌘" layout, this
returned the Dvorak V position, but when Command is held, this hybrid
layout switches to QWERTY positions—causing a mismatch and error beep.

Added detection for hybrid layouts (currently "Dvorak — QWERTY ⌘") that
use QWERTY positions for Command shortcuts. For these layouts, we use
the hardcoded QWERTY V key code (9). All other layouts continue using
Sauce's layout-aware key code.

Fixes kitlangton#162

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@darknoon darknoon force-pushed the dvorak-qwerty-insertion branch from a584fc9 to 170fb2c Compare January 29, 2026 18:58
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.

Insertion broken on "Dvorak — QWERTY ⌘" keyboard layout

1 participant