FR: Add support for more multimedia keys

I’ve been trying to use JUCE for a general media app and found myself stuck when trying to configure an assortment of input shortcuts. This is particularly off-putting because I need to use a remote control for the app on an embedded device.

To summarise the missing media key input functionality:

  • pause (Note that this is different than the play/pause key)
  • stop
  • volume up
  • volume down
  • mute
  • record
  • channel up
  • channel down
  • find/search
  • help

For Windows:

  • VK_PAUSE + APPCOMMAND_MEDIA_PAUSE
  • VK_MEDIA_STOP + APPCOMMAND_MEDIA_STOP
  • VK_VOLUME_DOWN + APPCOMMAND_VOLUME_DOWN
  • VK_VOLUME_UP + APPCOMMAND_VOLUME_UP
  • VK_VOLUME_MUTE + APPCOMMAND_VOLUME_MUTE
  • APPCOMMAND_MEDIA_CHANNEL_UP
  • APPCOMMAND_MEDIA_CHANNEL_DOWN
  • APPCOMMAND_FIND
  • VK_HELP + APPCOMMAND_HELP

In terms of Linux’s input events (which JUCE doesn’t apparently use, unless I’m confused? See https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h ):

  • KEY_PAUSE
  • KEY_STOP
  • KEY_VOLUMEUP
  • KEY_VOLUMEDOWN
  • KEY_MUTE
  • KEY_RECORD
  • KEY_CHANNELUP
  • KEY_CHANNELDOWN
  • KEY_FIND
  • KEY_HELP

Some investigations have found this for Linux/X11, but it’s incomplete in terms of media keys: https://cgit.freedesktop.org/xorg/proto/x11proto/tree/XF86keysym.h#n36

  • XF86XK_AudioPause
  • XF86XK_AudioStop
  • XF86XK_AudioRaiseVolume
  • XF86XK_AudioLowerVolume
  • XF86XK_AudioMute
  • XF86XK_AudioRecord

For macOS, this is what I could conjure up:

  • NSPauseFunctionKey
  • NSStopFunctionKey
  • NSPauseFunctionKey
  • NSFindFunctionKey
  • NSHelpFunctionKey

Note: it looks like macOS idiotically controls volume up/down/mute at a lower level. See: https://developer.apple.com/documentation/appkit/nsevent/1535851-function-key_unicodes

Note that some function keys are handled at a lower level and are never seen by your app. They include the Volume Up key, Volume Down key, Volume Mute key, Eject key, and Function key found on many computers.


For Android:

  • KEYCODE_MEDIA_PAUSE
  • KEYCODE_MEDIA_STOP
  • KEYCODE_VOLUME_UP
  • KEYCODE_VOLUME_DOWN
  • KEYCODE_VOLUME_MUTE
  • KEYCODE_MEDIA_RECORD
  • KEYCODE_CHANNEL_UP
  • KEYCODE_CHANNEL_DOWN
  • KEYCODE_SEARCH
  • KEYCODE_HELP

Possibly related to this, I’ve noticed that JUCE-based apps on Windows prevent global media hotkeys from working correctly when they have focus. For example, if I have a music player minimized, the player responds to media key presses correctly when other apps have focus, unless they are JUCE apps (observed with Projucer, DemoRunner, and my own apps).

I haven’t had the time yet to do any debugging and I’m on a laptop without media keys at the moment, so I’m not sure if this is really related to the FR or if it’s a separate issue.

My votes are stuck in old Feature Requests, but this would be great!
(I cannot even like it, because the likes in this category would be a vote).