Easily handle media keys on OS X.
osxmmkeys is a simple Python library for handling media keys on OS X. Key presses can be observed with no side effects, or have their default behaviours overridden entirely.
To install osxmmkeys with pip, use:
$ pip install osxmmkeys
import osxmmkeys def handler(): print("Play/pause key was pressed") tap = osxmmkeys.Tap() tap.on('play_pause', handler) tap.run()
import osxmmkeys, time def handler(): print("Play/pause key was pressed") tap = osxmmkeys.Tap() tap.on('play_pause', handler) tap.start() try: while True: time.sleep(1) except (KeyboardInterrupt, SystemExit): tap.stop()
Supported key names:
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
osxmmkeys-1.0.1.tar.gz (3.7 kB view hashes)