global-hotkeys

Implement system-wide macOS keyboard shortcuts using NSEvent monitoring and Carbon EventHotKey API.

1|Updated Feb 6, 2026
One-click install
npx skills add https://github.com/makgunay/claude-swift-skills --skill global-hotkeys
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: global-hotkeys
Source: https://github.com/makgunay/claude-swift-skills/tree/main/global-hotkeys
Command: npx skills add https://github.com/makgunay/claude-swift-skills --skill global-hotkeys

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you implement and manage system-wide keyboard shortcuts (hotkeys) on macOS, ensuring your applications can respond to user-defined key combinations reliably.

Core Features & Use Cases

  • System-Wide Hotkey Registration: Use Carbon's RegisterEventHotKey for robust, system-wide hotkey support, even for sandboxed applications.
  • In-App Shortcuts: Leverage SwiftUI's .onKeyPress and .keyboardShortcut for shortcuts within your application's UI.
  • Event Monitoring: Utilize NSEvent.addGlobalMonitorForEvents and addLocalMonitorForEvents for broader key event detection.
  • Use Case: Create a macOS app that triggers a specific action (e.g., opening a hidden panel) when the user presses Command + Shift + K, regardless of which application is currently active.

Quick Start

Use the global-hotkeys skill to register a system-wide hotkey for Command+Shift+A.

Frequently Asked Questions about global-hotkeys

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I register a global hotkey on macOS that works even when my app is in the background?

To register a global hotkey on macOS, you can use Carbon's RegisterEventHotKey API for robust system-wide keyboard shortcut support. This ensures your application responds to key combinations reliably, even when sandboxed or not actively focused.

What is the difference between NSEvent monitoring and Carbon EventHotKey for macOS keyboard shortcuts?

NSEvent monitoring via addGlobalMonitorForEvents detects key events system-wide but is observational. Carbon's EventHotKey API actively registers system-wide hotkeys, providing robust shortcut registration that triggers specific app actions even in sandboxed environments.

Can I use SwiftUI to handle in-app keyboard shortcuts and modifier flags?

Yes, SwiftUI supports in-app keyboard shortcuts using .onKeyPress and .keyboardShortcut modifiers. For broader event detection and modifier flag handling across the application, you can also utilize NSEvent addLocalMonitorForEvents.

Do I need Accessibility permissions to monitor system-wide key events on macOS?

Yes, utilizing NSEvent addGlobalMonitorForEvents for system-wide key event monitoring requires Accessibility permissions. This ensures your application has the necessary privileges to detect keyboard events occurring outside its own UI context.

How do I trigger a hidden panel in SwiftUI using a system-wide keyboard shortcut?

You can trigger a hidden panel by registering a system-wide hotkey using Carbon's RegisterEventHotKey. This allows your app to detect a specified key combination like Command+Shift+K and open the panel regardless of the active application.