Standard function keys on external keyboards in MacOS
Configure Karabiner Elements to use standard function keys on external keyboards while keeping media keys on your MacBook.
If you use an external keyboard with your MacBook, you’ve likely encountered an annoying issue: macOS treats function keys the same way across all keyboards. This means you either get media keys everywhere or standard function keys everywhere.
The ideal setup is having your external keyboard send standard F1-F12 keys (useful for development, gaming, or applications that rely on function keys) while your MacBook’s built-in keyboard retains the media key functionality (brightness, volume, playback controls).
The Solution
Karabiner Elements allows us to create device-specific key mappings using complex modifications. The key is the device_if condition with is_built_in_keyboard, which lets us target only the MacBook’s internal keyboard.
Configuration
First, ensure you have Karabiner Elements installed. If not, download it from karabiner-elements.pqrs.org or install it using brew.
Open your Karabiner configuration file located at ~/.config/karabiner/karabiner.json. Find the complex_modifications section and add the following rule:
{
"description": "Built-in keyboard: F-keys as media keys",
"manipulators": [
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f1" },
"to": [{ "consumer_key_code": "display_brightness_decrement" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f2" },
"to": [{ "consumer_key_code": "display_brightness_increment" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f3" },
"to": [{ "key_code": "mission_control" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f4" },
"to": [{ "key_code": "launchpad" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f5" },
"to": [{ "apple_vendor_top_case_key_code": "illumination_down" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f6" },
"to": [{ "apple_vendor_top_case_key_code": "illumination_up" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f7" },
"to": [{ "consumer_key_code": "rewind" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f8" },
"to": [{ "consumer_key_code": "play_or_pause" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f9" },
"to": [{ "consumer_key_code": "fastforward" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f10" },
"to": [{ "consumer_key_code": "mute" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f11" },
"to": [{ "consumer_key_code": "volume_decrement" }],
"type": "basic"
},
{
"conditions": [
{
"identifiers": [{ "is_built_in_keyboard": true }],
"type": "device_if"
}
],
"from": { "key_code": "f12" },
"to": [{ "consumer_key_code": "volume_increment" }],
"type": "basic"
}
]
}
System Preferences Setting
For this configuration to work correctly, you need to enable “Use F1, F2, etc. keys as standard function keys” in System Settings:
- Open System Settings (or System Preferences on older macOS versions)
- Navigate to Keyboard
- Enable “Use F1, F2, etc. keys as standard function keys”
This setting makes all keyboards send standard function keys by default. Our Karabiner rule then intercepts only the built-in keyboard and remaps those keys back to media functions.
How It Works
The configuration uses these key concepts:
device_ifcondition: Targets specific keyboards based on properties likeis_built_in_keyboardconsumer_key_code: Maps to media keys (volume, brightness, playback)apple_vendor_top_case_key_code: Maps to Apple-specific keys (keyboard backlight)key_code: Maps to system functions (Mission Control, Launchpad)
Function Key Mapping Reference
| Key | Built-in Keyboard | External Keyboard |
|---|---|---|
| F1 | Brightness Down | F1 |
| F2 | Brightness Up | F2 |
| F3 | Mission Control | F3 |
| F4 | Launchpad | F4 |
| F5 | Keyboard Light - | F5 |
| F6 | Keyboard Light + | F6 |
| F7 | Rewind | F7 |
| F8 | Play/Pause | F8 |
| F9 | Fast Forward | F9 |
| F10 | Mute | F10 |
| F11 | Volume Down | F11 |
| F12 | Volume Up | F12 |
With this setup, you get the best of both worlds: full media key functionality on your MacBook and standard function keys on your external keyboard.