Skip to main content

Bind a global hotkey, on macOS, in Python

Project description

This is a set of minimal Python bindings for the undocumented macOS framework APIs that even the most modern, sandboxing-friendly shortcut-binding frameworks use under the hood for actually binding global hotkeys.

Unlike something full-featured like MASShortcut, this provides no configuration UI; you have to provide keyboard constants directly.

Simple example:

from quickmachotkey import quickHotKey, mask
from quickmachotkey.constants import kVK_ANSI_X, cmdKey, controlKey, optionKey

@quickHotKey(virtualKey=kVK_ANSI_X, modifierMask=mask(cmdKey, controlKey, optionKey))
def handler() -> None:
    print("handled ⌘⌃⌥X")

if __name__ == "__main__":
    from AppKit import NSApplication  # type:ignore[import]
    from PyObjCTools import AppHelper  # type:ignore[import]
    print("type ⌘⌃⌥X with any application focused")
    NSApplication.sharedApplication()
    AppHelper.runEventLoop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quickmachotkey-2025.7.28.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quickmachotkey-2025.7.28-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file quickmachotkey-2025.7.28.tar.gz.

File metadata

  • Download URL: quickmachotkey-2025.7.28.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for quickmachotkey-2025.7.28.tar.gz
Algorithm Hash digest
SHA256 7290908a150ca884f301a0b2490690309cd5857e836e97c7d9f6c9e6f74b8f13
MD5 10679f25c9faf40544856055c5aa3695
BLAKE2b-256 b6f53de969ae98db8f438487d6987587ae3032f5b894f7e28af3114954c9b503

See more details on using hashes here.

File details

Details for the file quickmachotkey-2025.7.28-py3-none-any.whl.

File metadata

File hashes

Hashes for quickmachotkey-2025.7.28-py3-none-any.whl
Algorithm Hash digest
SHA256 bee42c752691add6aec4d6c6a044ef6fe1a6ced7e8b7308992f03d7c0fdc22cc
MD5 12b10937615fb3beba7b28f5b3165324
BLAKE2b-256 bfba9e60662622190296b46dda4b676c31a3d19b3c8f930444f9b68e43fa3f8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page