Skip to content

malpern/KeyPath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

KeyPath - Simple Keyboard Remapping for macOS

KeyPath

Remap any key to any other key with a simple, native macOS app

macOS 15+ Swift 6.0 License


🎯 What is KeyPath?

KeyPath is Kanata made easy for macOS.

Kanata is a powerful, cross-platform keyboard remapping engine that can transform your keyboard into exactly what you need. However, using Kanata on macOS requires navigating a maze of technical challenges:

  • Driver installation via command line
  • Permission debugging (TCC, Input Monitoring, Accessibility)
  • Service management (launchd, LaunchDaemons, SMJobBless)
  • Configuration syntax written by hand in Kanata's DSL
  • Code signing & notarization for system-level access
  • Debugging when things go wrong

KeyPath eliminates all of this complexity while preserving Kanata's full power. You get enterprise-grade keyboard remapping with consumer-grade ease of use.

The Problem KeyPath Solves

Before KeyPath: To remap keys on macOS with Kanata, you need to:

  1. Install the Karabiner VirtualHID driver manually
  2. Understand macOS security frameworks (TCC)
  3. Configure launchd services with root privileges
  4. Write Kanata configuration files in a custom syntax
  5. Debug permission issues, service conflicts, and connectivity problems
  6. Handle code signing and notarization for system components

With KeyPath: Click record, press keys, click save. Done.

KeyPath is a complete macOS integration layer that:

  • βœ… Handles all system setup automatically
  • βœ… Provides a beautiful, native SwiftUI interface
  • βœ… Manages permissions, services, and drivers
  • βœ… Generates Kanata configurations from visual recordings
  • βœ… Offers intelligent troubleshooting and diagnostics
  • βœ… Ensures reliable operation with proper system integration

✨ Why Use KeyPath?

🎯 Dead Simple Workflow

No configuration files, no command line, no technical knowledge required.

  1. Click "Record Input"
  2. Press the key(s) you want to remap
  3. Click "Record Output"
  4. Press what you want it to do
  5. Click Save

Your remapping is active immediatelyβ€”no restart, no manual service management, no file editing.

⚑ Instant & Reliable

  • Hot reload - Changes apply instantly via UDP communication
  • System integration - Runs as LaunchDaemon, works at boot time
  • Crash recovery - Automatic service restart and conflict resolution
  • Health monitoring - Real-time status checks and diagnostics

πŸ›‘οΈ Safe & Secure

  • Emergency stop - Press Ctrl + Space + Esc to immediately disable all remappings
  • Permission wizard - Guided setup handles all macOS security requirements
  • Conflict detection - Automatically detects and resolves system conflicts
  • No telemetry - Works completely offline, no data collection

🎨 Native macOS Experience

  • Beautiful SwiftUI interface with Liquid Glass design (macOS 15+)
  • System Settings integration - Follows macOS design patterns
  • Proper signing & notarization - Works with macOS security features
  • Accessibility support - Respects macOS accessibility settings

πŸ”§ Enterprise-Grade Architecture

Built on proven patterns (inspired by Karabiner-Elements):

  • LaunchDaemon architecture - Reliable system-level service management
  • File-based configuration - Simple, debuggable, hot-reloadable
  • Single source of truth - PermissionOracle prevents inconsistent state
  • State-driven wizard - Handles 50+ edge cases automatically

πŸš€ Getting Started

Installation

Option 1: Download Release (Recommended)

  1. Download from the Releases page
  2. Open KeyPath.app
  3. Follow the setup wizard

Option 2: Build from Source

git clone https://github.com/malpern/KeyPath.git
cd KeyPath

# Canonical build (builds, signs, notarizes, deploys to ~/Applications, restarts app)
./build.sh

The build script automatically:

  • Compiles the Swift package
  • Signs all components with Developer ID
  • Notarizes the app bundle
  • Installs to ~/Applications/
  • Restarts the app

First Launch

When you first launch KeyPath, the Installation Wizard will guide you through:

  1. Permission Setup - Grants Input Monitoring and Accessibility permissions
  2. Driver Installation - Installs Karabiner VirtualHID driver if needed
  3. Service Configuration - Sets up LaunchDaemon services
  4. System Validation - Verifies everything is working correctly

The wizard handles all technical setup automatically and provides one-click fixes for common issues.

Create Your First Mapping

  1. Record Input: Click the record button next to "Input Key"

    • Press a single key (e.g., Caps Lock)
    • Or a key combo (e.g., Cmd+Space)
    • Or a sequence (e.g., press A, then B, then C)
  2. Record Output: Click the record button next to "Output Key"

    • Press what you want it to do (e.g., Escape)
    • Or a combo (e.g., Cmd+C for copy)
    • Or type multiple keys (e.g., "hello world")
  3. Save: Click Save - your mapping is now active!


🎁 Features

For Everyone

Feature Description
Flexible Input Record single keys, combos (Cmd+C), or sequences (A→B→C)
Flexible Output Map to single keys, combos, or entire phrases
Visual Recording See exactly what keys you're pressing in real-time
Instant Apply Changes work immediately - no restart needed
Safety Features Emergency stop (Ctrl+Space+Esc) prevents getting locked out
Smart Setup Installation wizard handles all technical setup automatically
Native macOS UI Beautiful SwiftUI interface with Liquid Glass design (macOS 15+)

For Power Users

Feature Description
Complex Mappings Chain multiple actions from a single trigger
Hot Reload Edit config files directly, changes apply instantly via UDP
System Integration Runs as LaunchDaemon at startup, works everywhere
Extensive Logging Debug issues with detailed logs and diagnostics
Full Kanata Power Access to all of Kanata's remapping capabilities
Configuration Access Edit Kanata configs directly if needed

πŸ“‹ Common Use Cases

Popular Remappings

  • Caps Lock β†’ Escape - Essential for Vim users
  • Right Cmd β†’ Delete - Easier reach for frequent deleters
  • F1-F12 β†’ Media Keys - Volume, brightness, playback control
  • Broken Key Workaround - Remap a broken key to a working one

Advanced Uses

  • Hyper Key - Turn Caps Lock into Cmd+Ctrl+Alt+Shift combo
  • App Launchers - Map key sequences to launch favorite apps
  • Text Snippets - Type your email address with a key combo
  • Gaming - Create custom key combinations for complex moves
  • Workflows - Map one key to perform multiple actions in sequence

πŸ—οΈ Architecture & Technical Details

What Makes KeyPath Different

KeyPath isn't just a wrapper around Kanataβ€”it's a complete macOS integration layer that solves real problems:

1. Intelligent Permission Management

  • PermissionOracle - Single source of truth for all permission detection
  • Handles macOS TCC (Transparency, Consent, Control) complexity
  • Detects permission issues before they cause problems
  • Provides one-click fixes for common permission problems

2. Automated System Setup

  • Installs and manages Karabiner VirtualHID driver
  • Handles code signing and notarization for all components
  • Manages LaunchDaemon services and lifecycle
  • Resolves conflicts with other keyboard remappers automatically

3. Visual Configuration Generation

  • Converts visual key recordings into valid Kanata configuration
  • Handles complex modifier combinations and sequences
  • Generates optimized Kanata configs automatically
  • No need to learn Kanata's configuration syntax

4. Reliable Service Management

  • LaunchDaemon architecture ensures remappings work at boot time
  • Automatic crash recovery and conflict resolution
  • Health monitoring with real-time status checks
  • Hot reload via UDP for instant configuration updates

5. Comprehensive Diagnostics

  • Built-in system state detection
  • Automatic log analysis and error interpretation
  • Visual permission status with fix suggestions
  • Real-time service health monitoring

Technical Stack

  • Swift 6.0 - Modern Swift concurrency (async/await, actors)
  • SwiftUI - Native macOS UI with Liquid Glass design
  • Kanata - Cross-platform keyboard remapping engine
  • LaunchDaemon - System-level service management
  • Karabiner VirtualHID - macOS HID driver for system-level remapping

πŸ›‘οΈ Safety & Security

Emergency Stop

If your keyboard becomes unresponsive, press Ctrl + Space + Esc simultaneously. This immediately disables all remappings and restores normal keyboard functionality.

Low Power Safeguard

  • KeyPath watches your Mac's battery level using the built-in power APIs.
  • When charge drops under 5%, you'll see a πŸͺ« system toast inviting you to pause Kanata to prevent sticky keys or missed strokes.
  • If you accept, KeyPath pauses the remapper and clearly labels the app as "Paused (Low Power)" until the battery recovers.
  • Once the battery climbs back above the safe zone, KeyPath automatically resumes Kanata and sends a follow-up notification so you can keep working.

Permission Requirements

KeyPath needs two macOS permissions to work:

  1. Input Monitoring - To detect key presses
  2. Accessibility - To send remapped keys

The setup wizard guides you through granting these permissions with one-click access to System Settings.

Kanata binary location (LaunchDaemon)

For stable TCC permissions, LaunchDaemon services use the system-installed kanata binary:

/Library/KeyPath/bin/kanata

The helper keeps this binary updated from the bundled copy when needed and ensures proper ownership/permissions. The bundled binary inside KeyPath.app is not used by LaunchDaemons.

What KeyPath Does NOT Do

  • ❌ No internet connection required (offline by default; optional AI config generation contacts Anthropic if ANTHROPIC_API_KEY is present)
  • ❌ No data collection or telemetry
  • ❌ No modification of system files
  • ❌ No kernel extensions

πŸ”§ Troubleshooting

KeyPath Won't Start?

  1. Check macOS version - Requires macOS 15.0 (Sequoia) or later
  2. Run setup wizard - Go to File β†’ Run Setup Wizard
  3. Check logs - View system logs: tail -f /var/log/kanata.log

Keys Not Remapping?

  1. Check status indicator - Look for green checkmarks in the app
  2. Verify permissions - Ensure permissions granted in System Settings
  3. Use Fix Issues - Click "Fix Issues" button in the app for automated fixes

Need More Help?

Developer Notes

Xcode 26 beta test runner crash (Swift 6.2)

If you're using Xcode 26.0 beta, swift test can crash with SIGABRT after tests pass. Use the workaround:

./run-tests-workaround.sh

Our main test runners (./run-tests.sh and ./Scripts/run-tests.sh) already include this workaround.


πŸ—οΈ Requirements

System Requirements

  • macOS 15.0 (Sequoia) or later
  • Apple Silicon or Intel Mac

Dependencies (Handled Automatically)

  • Kanata - The remapping engine (bundled with app)
  • Karabiner VirtualHID Driver - For system-level key events

The setup wizard automatically checks for these and helps you install them if needed.


🚫 Uninstallation

Recommended Method

  1. Open KeyPath
  2. Go to File β†’ Uninstall KeyPath
  3. Follow the prompts

Manual Uninstallation

sudo ./Scripts/uninstall.sh

This removes:

  • LaunchDaemon services
  • System binaries
  • Configuration files
  • Application bundle

🀝 Contributing

We welcome contributions! KeyPath is designed to make keyboard remapping accessible to everyone, and contributions help make it better.

Quick Start for Contributors

# Clone the repository
git clone https://github.com/malpern/KeyPath.git
cd KeyPath

# Build and test (development)
swift build
swift test

# Production-like build & deploy (recommended for real testing)
./build.sh
mkdir -p ~/Applications && cp -R dist/KeyPath.app ~/Applications/
osascript -e 'tell application "KeyPath" to quit' || true
open ~/Applications/KeyPath.app

See CONTRIBUTING.md for detailed guidelines, architecture overview, and contribution patterns.


πŸ“š Documentation


πŸ“„ License

MIT License - see LICENSE for details.


πŸ™ Acknowledgments

KeyPath stands on the shoulders of giants:

  • Kanata - The powerful keyboard remapping engine that powers KeyPath
  • Karabiner-Elements - VirtualHID driver and architectural inspiration
  • SwiftUI - For the beautiful, native macOS experience
  • macOS Security Team - For the robust security frameworks that make safe keyboard remapping possible

Made with ❀️ for the macOS community

If KeyPath helps you, consider ⭐ starring the repo!

KeyPath makes Kanata's power accessible to everyoneβ€”no command line required.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •