Standard function keys on external keyboards in MacOS

Standard function keys on external keyboards in MacOS
Date
Tags
MacOS
Utilities
Karabiner

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:

  1. Open System Settings (or System Preferences on older macOS versions)
  2. Navigate to Keyboard
  3. 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_if condition: Targets specific keyboards based on properties like is_built_in_keyboard
  • consumer_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

KeyBuilt-in KeyboardExternal Keyboard
F1Brightness DownF1
F2Brightness UpF2
F3Mission ControlF3
F4LaunchpadF4
F5Keyboard Light -F5
F6Keyboard Light +F6
F7RewindF7
F8Play/PauseF8
F9Fast ForwardF9
F10MuteF10
F11Volume DownF11
F12Volume UpF12

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.

More Articles