Skip to content

Add visual keyboard layout editor and cheatsheet - #296

Closed
kevintraver wants to merge 25 commits into
mikker:mainfrom
kevintraver:feat/keyboard-layout
Closed

kevintraver wants to merge 25 commits into
mikker:mainfrom
kevintraver:feat/keyboard-layout

Conversation

@kevintraver

@kevintraver kevintraver commented Dec 15, 2025 •

Copy link
Copy Markdown

Adds a visual keyboard interface for both editing and viewing shortcuts.

Features

Keyboard Editor - A new Settings tab that displays a full QWERTY keyboard. Click any key to add or edit actions and groups directly on the layout.

Keyboard Cheatsheet - An alternative to the list-style cheatsheet that shows your bindings overlaid on a keyboard. Toggle between styles in Advanced preferences.

Screenshot

image

Technical Details

  • New KeyboardLayout module: KeyboardLayoutModel, KeyboardLayoutView, KeyView
  • KeyboardCheatsheetView for overlay display of bindings
  • KeyboardPane settings tab with unified editor for actions and groups
  • Modifier key monitoring in Controller for real-time shift state
  • Cheatsheet style preference stored in UserDefaults
  • Extracted reusable components: KeyBadge, CheatsheetRows

Adds a visual keyboard interface for both editing and viewing shortcuts:

- Keyboard Editor: A new Settings tab that displays a full QWERTY keyboard. Click any key to add or edit actions and groups directly on the layout.
- Keyboard Cheatsheet: An alternative to the list-style cheatsheet that shows your bindings overlaid on a keyboard. Toggle between styles in preferences.

Technical Details:
- New KeyboardLayout module: KeyboardLayoutModel, KeyboardLayoutView, KeyView
- KeyboardCheatsheetView for overlay display of bindings
- KeyboardPane settings tab with unified editor for actions and groups
- Modifier key monitoring in Controller for real-time shift state
- Cheatsheet style preference stored in UserDefaults
- Extracted reusable components: KeyBadge, CheatsheetRows

🤖 Generated with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
kevintraver and others added 24 commits December 15, 2025 13:50
Change material from hudWindow to popover and add semi-transparent
window background overlay (70% opacity) for better contrast while
maintaining blur effect.
…ition

Update the keyboard cheatsheet centering logic to align with the main
theme window positioning. Both windows now share the same vertical offset
(slightly above true center) for consistent visual alignment.

Changes:
- Modified centerCheatsheetWindow to use theme-matching vertical offset
- Added multiple centering passes to handle SwiftUI layout timing
- Improved showCheatsheet timing to ensure proper sizing before display

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Simplified the group editing interface by removing redundant elements and
improving the action flow with clearer button labels.

Changes:
- Removed "Edit Group Layout" button from group editor body
- Removed helper text "Assign actions to keys within this group"
- Changed "Done" button to "Assign Actions" for groups
- Added "Cancel" button for groups to dismiss without saving
- "Assign Actions" button now saves and opens keyboard layout in one step

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
… button

- Replace "Root" text with house icon for cleaner UI
- Use default macOS button styling for breadcrumb buttons
- Adjust breadcrumb alignment to match keyboard layout edges
- Add balanced left/right spacing for proper visual alignment

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Align spacebar left edge with C key and right edge with comma key
- Adjust spacebar width from 6.5u to 6.0u for accurate alignment
- Balance right Cmd (1.5u) and Opt (1.5u) keys to meet under slash key
- Maintain total bottom row width at 15 units

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace single group label with full breadcrumb path showing navigation hierarchy.
Breadcrumbs are read-only (non-interactive) for display purposes only.
…orners

Enhanced favicon presentation in keyboard layout and cheatsheet views:
- Enabled favicon loading in keyboard layout (was previously disabled)
- Removed padding to display favicons at full icon size
- Added rounded corners (20% radius) to match app icon styling
- Maintained aspect ratio with .fit content mode for better appearance

Favicons now match the visual style of native app icons throughout the UI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add a new Stats tab in settings to help users identify their most-used
actions and optimize their keyboard shortcut configurations.

Features:
- Track every action execution with timestamps and key paths
- Store stats in SQLite database using GRDB.swift
- Display grouped stats by parent group with usage counts
- Show keyboard shortcuts inline with action names
- Clear all stats with confirmation dialog

Implementation:
- StatsDatabase.swift: Define ActionExecution and ActionStats models
  with GRDB migrations and indexes
- StatsManager.swift: Singleton for recording executions and querying
  aggregated statistics
- StatsPane.swift: SwiftUI settings pane with grouped display showing
  [key] Action Name (count) format
- Hook stats recording into Controller.runAction() with full key path

Database stored at ~/Library/Application Support/Leader Key/stats.db

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Integrates usage statistics tracking alongside keyboard layout features:
- Add Stats settings pane with StatsManager
- Add Keyboard settings pane with layout editor
- Track action executions and group navigation
Update StatsPane to properly wrap content in Settings.Section components
with required title parameter, fixing build errors after Settings library
update.
- Fix rowWidth calculation to properly count gaps between keys instead of
  using total width units
- Simplify keyboard centering in KeyboardPane by using center alignment
  and frame width instead of manual spacer calculations
- Remove complex left/right offset logic for cleaner layout code

This fixes spacing issues where keyboard rows were misaligned.
- Fix rowWidth calculation to properly count gaps between keys instead of
  using total width units
- Simplify keyboard centering in KeyboardPane by using center alignment
  and frame width instead of manual spacer calculations
- Remove complex left/right offset logic for cleaner layout code

This fixes spacing issues where keyboard rows were misaligned.
Add support for custom image files as icons alongside existing app
icons. Users can now select PNG, JPEG, or ICNS files from the "Custom
Icon..." menu option.

Changes:
- Add CustomIconImage SwiftUI view for rendering custom icons
- Add "Custom Icon..." option to icon picker menu
- Add file picker handlers for Actions and Groups
- Apply proper sizing and rounded corners to match app bundle icons
- Add validation to ensure selected files are valid images

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Merge custom PNG/JPEG/ICNS icon support feature. Combines:
- Stats tracking feature (from main)
- URL scheme handler support (from feature branch)
- Custom icon support for actions and groups

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add support for custom image files as icons alongside existing app
icons. Users can now select PNG, JPEG, or ICNS files from the "Custom
Icon..." menu option.

Changes:
- Add CustomIconImage SwiftUI view for rendering custom icons
- Add "Custom Icon..." option to icon picker menu
- Add file picker handlers for Actions and Groups
- Apply proper sizing and rounded corners to match app bundle icons
- Add validation to ensure selected files are valid images

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…heet is visible

Skip updating userState.display in centered cheatsheet mode since the
keyboard cheatsheet already shows navigation state via breadcrumbs.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- Drag a bound key onto another key to move or swap bindings; root group
  shortcuts follow the moved binding
- Resolve key labels and binding keys from the active input source unless
  Force English is on
- Show binding names in the keyboard cheatsheet
- Share one key-width calculation so rowWidth matches what is drawn
- Size favicons like other key icons
- Remove unused keyboard pane state and the isEditable parameter
- Add model tests for row widths, shifted keys and layout resolution

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The keyboard switched between 1.0x and 1.4x on every open and hide, which
rebuilt all 60 keys and reloaded every icon each time. It is only ever
shown centered, so the scale is now fixed. Drawing on open drops from a
median of 55 ms to 10 ms (Release, 30 opens per side in a VM).

The view now observes UserConfig directly, since the scale flip was also
what made config edits appear on the next open.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Entering a group decoded each of its icon files from disk on the main
thread every time. Rendered icons are now kept in memory and dropped when
the config reloads. Entering a group with 14 icons goes from a median of
34 ms to 15 ms after the first visit (Release, 25 entries per side in a VM).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Deleting a group that has bindings asks first, and deleting a top-level
group also removes its global shortcut.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikker

mikker commented Nov 11, 2026

Copy link
Copy Markdown
Owner

I still really love this however not maintaining Leader Key.
#323 (comment)

Bringing something like it to Tuna. Thank you for the work and the suggestion

@kevintraver

Copy link
Copy Markdown
Author

I still really love this however not maintaining Leader Key. #323 (comment)

Bringing something like it to Tuna. Thank you for the work and the suggestion

Thanks! I'll close out this PR.

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.

2 participants