I know this question is old, but other answers don’t really solve the problem.
All you have to do is to install Karabiner (previously known as KeyRemap4MacBook).
Then you just have to add the wanted behavior.
- Switch to
Misc & Uninstalltab
- Click on
- Open the file
private.xmlin your favorite Text Editor
Replace the empty file by this definition :
<?xml version="1.0"?> <root> <!-- Spotify Path --> <vkopenurldef> <name>KeyCode::VK_OPEN_URL_APP_Spotify</name> <url type="file">/Applications/Spotify.app</url> </vkopenurldef> <!-- Set Spotify definition --> <appdef> <appname>SPOTIFY</appname> <equal>com.spotify.client</equal> </appdef> <!-- Use 'Music Play' key to launch Spotify if not ever in the application --> <!-- else, act as normal play/pause button in Spotify, Itunes --> <item> <name>Change Play key to launch Spotify</name> <identifier>private.play_launch_spotify</identifier> <not>SPOTIFY, ITUNES</not> <autogen> __KeyToKey__, ConsumerKeyCode::MUSIC_PLAY, KeyCode::VK_OPEN_URL_APP_Spotify, </autogen> </item> </root>
Go back to
Change Keytab and click on
You now just have to enable the new item added at the top of the list:
You might find this useful, too. How to prevent iTunes from launching on media key press
Spotify should respond to F8 by default. How do you get the awesome
I would add a custom Keyboard Shortcut to your Function Keys F8-F12.
Normally you would access these function keys by holding fn and the associated Media Key. For example F8 = fn + (Play/Pause on newer Macbook Pros)
In order to make the function keys, rather than their media key functionality, default I would use Function Flip (Free)
To open Spotify and play a song on launch you could do this in AppleScript:
tell application "Spotify" activate play track "spotify:track:trackURI" end tell
Export this script as an Application with the option “Save as executable script” (or something similar).
Then, to map your f8 key to this script, go to System Preferences, and then under “Keyboard” enable “Use All F1, F2, etc, keys as standard function keys”. For the next step, you need to switch to the “Keyboard Shortcuts” tab and add a new Keyboard Shorcut under Applications that will open the AppleScript. (If I remember correctly, you have to reboot your computer or log out for the changes to take place)