MacOS – How to create duplicate pair of keyboard media keys for use with iTunes and streaming websites

google-chromeituneskeyboardmacos

I've recently installed the Google Chrome extension Streamkeys which allows the user to use keyboard commands to perform common playback actions on popular streaming sites (Youtube, Soundcloud, and many major sites).

For macOS, Streamkeys default setting is to use the global Mac media keys ( ▶/❚❚ ).

Due to Chrome design, global keys cannot be rebound to use modifier keys like SHIFT + ▶/❚❚.

I like the idea of using the media keys for global Soundcloud/Youtube control, so what I'd like to do is to rebind the keyboard so that iTunes instead uses modifier keys like SHIFT + ▶/❚❚. That way, I can have the best of two worlds.

Question: How can I "duplicate" these three keys to a new location and use them to control iTunes, while still letting Chrome think that they are in their old location? In other words, I would effectively like two pairs of the same keys, only that one pair controls iTunes and one pair controls Chrome Streamkeys.

Is this even possible, and am I thinking about it the right way, when assuming that I would need "duplicates"? Just rebinding the keys would probably not work, since Chrome would still find the keys and "take them" for Streamkeys?

Note again: this is about global control. It is not the same as in-tab in Chrome or in-app in iTunes.

Best Answer

Install Karabiner

Which can be found there: Karabiner: a keyboard customizer for OS X

Analyse which keys are involved

Within Karabiner menu select Launch EventViewer... and type on the music control key you would like to program. Here is the output you should get: Karabiner Event Viewer

Make a private.xml

Read the Karabiner documentation on the topic: private.xml Reference Manual

Create the ${HOME}/Library/Application Support/Karabiner/private.xml with the following content:

<?xml version="1.0"?>
<root>
  <item>
    <name>Shift standard music control keys</name>
    <identifier>Shift standard music control keys</identifier>
    <autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_PREV, ModifierFlag::SHIFT_L, ConsumerKeyCode::MUSIC_PREV</autogen>
    <autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_PLAY, ModifierFlag::SHIFT_L, ConsumerKeyCode::MUSIC_PLAY</autogen>
    <autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_NEXT, ModifierFlag::SHIFT_L, ConsumerKeyCode::MUSIC_NEXT</autogen>
  </item>
</root>

Depending of your taste, use vi, emacs or TextEdit (of course not Word).

If you want to be clean, I would suggest you to proceed as I did.

Create a source with the above content in:

${HOME}/Documents/src/Karabiner/music.xml

and then install it within the Karabiner directory:

cp ${HOME}/Documents/src/Karabiner/music.xml "${HOME}/Library/Application Support/Karabiner/private.xml"

( The "…" use is necessary because of the space within Application Support. ).

Load your private.xml

Tell Karabiner you will use a custom setting: Karabiner use prepared settings

and load it: Karabiner apply prepared settings

Test it

Check that this let you achieve the mapping you want to get with Chrome.

I didn't check this part of your request, and I am not sure I understood it fully.

Report success or failure, since this may help some other users ?.