A macOS menu bar application that allows you to switch input sources (keyboard layouts and input methods) by pressing the left or right Command key alone.
- Quick Input Source Switching: Switch between different input sources by pressing the left or right Command key alone
- Customizable Key Mapping: Assign different input sources to left and right Command keys
- Menu Bar Interface: Easy access to settings through the menu bar
- Persistent Configuration: Settings are saved automatically and restored on app launch
- Support for Multiple Input Sources: Works with any keyboard layout or input method installed on your Mac
Perfect for bilingual users who frequently switch between different keyboard layouts or input methods (e.g., switching between English and Japanese input). Instead of using traditional keyboard shortcuts like Ctrl+Space or Cmd+Space, you can switch input sources with a single Command key press.
- Press only the left Command key (without any other keys) → Switches to the input source assigned to the left Command key
- Press only the right Command key (without any other keys) → Switches to the input source assigned to the right Command key
- Using Command key with other keys (e.g.,
Cmd+C,Cmd+V) works normally as keyboard shortcuts
- macOS 12.0 (Monterey) or later
- Xcode 14.0 or later (for development)
The easiest way to install CmdSwitch is via Homebrew:
brew install --cask dongri/tap/cmd-switchDownload the latest release from GitHub Releases:
- Download
CmdSwitch.dmg - Open the DMG file
- Drag
Cmd Switch.appto Applications folder - Double-click to launch! ✨
Note: CmdSwitch is signed and notarized by Apple, so it will launch without any security warnings.
- Clone this repository:
git clone https://github.com/dongri/cmd-switch.git
cd cmd-switch- Open the project in Xcode:
open CmdSwitch.xcodeproj-
Build and run the project in Xcode (Cmd+R)
-
Grant accessibility permissions when prompted (required for monitoring keyboard events)
- Launch CmdSwitch
- Click the app icon in the menu bar
- Select input sources for left and right Command keys from the dropdown menus
- The app will automatically save your preferences
This app requires Accessibility permissions to monitor keyboard events. When you first launch the app, macOS will prompt you to grant these permissions in System Settings > Privacy & Security > Accessibility.
CmdSwitch/
├── CmdSwitchApp.swift # App entry point and menu bar setup
├── AppDelegate.swift # Event monitoring and input source switching logic
├── ContentView.swift # Settings UI
├── InputSourceManager.swift # Input source management and state handling
└── Assets.xcassets/ # App icons and assets
- CmdSwitchApp: Main app structure using SwiftUI's
MenuBarExtrafor menu bar integration - AppDelegate: Handles keyboard event monitoring using CGEvent tap, detects Command key presses, and triggers input source switching
- InputSourceManager: Manages available input sources, user preferences, and switching logic using Carbon's Text Input Source Services API
- ContentView: Provides the UI for selecting input sources for each Command key
- SwiftUI: For the user interface
- AppKit: For macOS integration and menu bar functionality
- Carbon Framework: For Text Input Source Services (TIS) API
- Core Graphics: For event tap and keyboard monitoring
- Accessibility API: For system-level keyboard event monitoring
- Open
CmdSwitch.xcodeprojin Xcode - Select your development team in the project settings
- Build the project (Cmd+B)
- Run the app (Cmd+R)
The app uses CGEvent.tapCreate to monitor keyboard events at the system level:
- Flags Changed Events: Detects when Command keys are pressed or released
- Key Down Events: Tracks if other keys are pressed while Command key is held
- Single Key Detection: Switches input source only when Command key is pressed and released without other keys
The app supports multiple methods for switching input sources:
- Japanese Input: Uses keyCode 104 (Kana key)
- English Input: Uses keyCode 102 (Eisu key)
- Other Input Sources: Uses
TISSelectInputSourceAPI
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Created by Dongri Jin