How to add keyboard shortcut to toggle F1, F2, etc. as standard function keys?
I saw an AppleScript on Github to automate toggling F1, F2, etc. as standard function keys, but I don't know how to install it to my system and trigger it via a keyboard shortcut. Help?
I am running OS X Yosemite 10.10.1. Here's the script: https://gist.github.com/alampros/2b81af6cfc564f6accd3
In order to assign a keyboard shortcut to this script, you could create a service in Automator.
You must change Service receives
to no input
. Then add Execute AppleScript
and paste your script. Save it on ~/Library/Services
.
Once saved, you must go to System Preferences → Keyboard → Shortcuts
and you can find out under Services → General
. Assign your preferred shortcut there.
Using Karabiner, you can save this file as ~/Library/Application Support/Karabiner/private.xml
:
<?xml version="1.0"?>
<root>
<item>
<name>fn+escape to toggle f-keys</name>
<identifier>fnesc</identifier>
<autogen>__KeyToKey__ KeyCode::ESCAPE, ModifierFlag::FN | ModifierFlag::NONE, KeyCode::VK_CONFIG_TOGGLE_fkeys</autogen>
</item>
<item>
<name>fkeys</name>
<identifier vk_config="true">fkeys</identifier>
<autogen>__KeyToKey__ ConsumerKeyCode::BRIGHTNESS_DOWN, KeyCode::F1</autogen>
<autogen>__KeyToKey__ ConsumerKeyCode::BRIGHTNESS_UP, KeyCode::F2</autogen>
<autogen>__KeyToKey__ KeyCode::EXPOSE_ALL, KeyCode::F3</autogen>
<autogen>__KeyToKey__ KeyCode::LAUNCHPAD, KeyCode::F4</autogen>
<autogen>__KeyToKey__ ConsumerKeyCode::KEYBOARDLIGHT_LOW, KeyCode::F5</autogen>
<autogen>__KeyToKey__ ConsumerKeyCode::KEYBOARDLIGHT_HIGH, KeyCode::F6</autogen>
<autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_PREV, KeyCode::F7</autogen>
<autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_PLAY, KeyCode::F8</autogen>
<autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_NEXT, KeyCode::F9</autogen>
<autogen>__KeyToKey__ ConsumerKeyCode::VOLUME_MUTE, KeyCode::F10</autogen>
<autogen>__KeyToKey__ ConsumerKeyCode::VOLUME_DOWN, KeyCode::F11</autogen>
<autogen>__KeyToKey__ ConsumerKeyCode::VOLUME_UP, KeyCode::F12</autogen>
<autogen>__KeyToKey__ KeyCode::F1, ConsumerKeyCode::BRIGHTNESS_DOWN</autogen>
<autogen>__KeyToKey__ KeyCode::F2, ConsumerKeyCode::BRIGHTNESS_UP</autogen>
<autogen>__KeyToKey__ KeyCode::F3, KeyCode::EXPOSE_ALL</autogen>
<autogen>__KeyToKey__ KeyCode::F4, KeyCode::LAUNCHPAD</autogen>
<autogen>__KeyToKey__ KeyCode::F5, ConsumerKeyCode::KEYBOARDLIGHT_LOW</autogen>
<autogen>__KeyToKey__ KeyCode::F6, ConsumerKeyCode::KEYBOARDLIGHT_HIGH</autogen>
<autogen>__KeyToKey__ KeyCode::F7, ConsumerKeyCode::MUSIC_PREV</autogen>
<autogen>__KeyToKey__ KeyCode::F8, ConsumerKeyCode::MUSIC_PLAY</autogen>
<autogen>__KeyToKey__ KeyCode::F9, ConsumerKeyCode::MUSIC_NEXT</autogen>
<autogen>__KeyToKey__ KeyCode::F10, ConsumerKeyCode::VOLUME_MUTE</autogen>
<autogen>__KeyToKey__ KeyCode::F11, ConsumerKeyCode::VOLUME_DOWN</autogen>
<autogen>__KeyToKey__ KeyCode::F12, ConsumerKeyCode::VOLUME_UP</autogen>
</item>
</root>
Then open the Karabiner application, press the ReloadXML button, and enable the setting.