moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.77k stars 245 forks source link

media_next and media_prev keys not recognized on MacBook Pro (Monterey) #475

Open gian-didom opened 2 years ago

gian-didom commented 2 years ago

Description The F7 and F9 keys (corresponding to the media playback command of prev and next) are not recognized at all. The key press is not even detected, while the middle (F8) key corresponding to play/pause is successfully recognized.

Platform and pynput version MacOS Monterey 12.2.1, pynput 1.7.6

To reproduce

from pynput.keyboard import Listener, Key

def on_press(key):
    if key == Key.media_play_pause:
        # play pause media key was pressed
        print('play')

    if key == Key.media_next:
        # next key was pressed
        print('next')

    if key == Key.media_prev:
        # previous key was pressed
        print('prev')

    else:
        print(key)
        print('hey')

def on_release(key):
    pass

listener_thread = Listener(on_press=on_press, on_release=None)
# This is a daemon=True thread, use .join() to prevent code from exiting  
listener_thread.start()
listener_thread.join()
moses-palmer commented 2 years ago

Thank you for your report.

Unfortunately, I do not have hardware capable of running that version of the operating system. Would you mind adding a simple print statement here locally on your machine to see what the values for event_type and event are?