自從 M2 Macbook Air 重新將 Fn
鍵回歸取代 Touch Bar 後,如何善用 Fn
鍵就成為重要的課題,畢竟 macOS 不像 Windows 常常會使用到 Fn
鍵。我們可使用 Karabiner-Elements 重新定義 Fn
鍵取代 Touch Bar 切換 app,並保留 ⌘
+ Fn
執行原本的功能。
Version
Karabiner-Elements 14.12.0
Installation
$ brew install --cask karabiner-elements
- 使用 Homebrew 安裝 Karabiner
Fn Keys
F1
:Safari
F2
:WebStorm
⌥ + F2
:Android Studio
F3
:WebP Converter
F4
:iTerm2
F5
:Typora
F6
:FortLift
F7
:Sublime Text
F8
:MOJi 辞書
F9
:ChatGPT
F10
:Gitfox
F11
:Chrome
F12
:Firefox
⌘+ F1
:Decrease Volumn
⌘ + F2
:Increase Volumn
⌘ + F3
:Mission Control
⌘ + F4
:Zoom
⌘ + F5
:Capture Text by TextSnipper
⌘ + F6
:Capture Screen by CleanShot X
⌘ + F7
:Rewind
⌘ + F8
:Play / Pause
⌘ + F9
:Foward
⌘ + F10
:Mute
⌘ + F11
:Decrease Volumn
⌘ + F12
:Increase Volumn
Karabinar Configuration
karabiner.json
{
"global": {
"ask_for_confirmation_before_quitting": true,
"check_for_updates_on_startup": true,
"show_in_menu_bar": false,
"show_profile_name_in_menu_bar": false,
"unsafe_ui": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
"basic.simultaneous_threshold_milliseconds": 50,
"basic.to_delayed_action_delay_milliseconds": 500,
"basic.to_if_alone_timeout_milliseconds": 1000,
"basic.to_if_held_down_threshold_milliseconds": 500,
"mouse_motion_to_scroll.speed": 100
},
"rules": [
{
"description": "Use F1 to Open Safari",
"manipulators": [
{
"from": {
"key_code": "f1"
},
"to": [
{
"shell_command": "open -a '/Applications/Safari.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F1 to Decrease Brightness",
"manipulators": [
{
"from": {
"key_code": "f1",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"consumer_key_code": "display_brightness_decrement"
}
],
"type": "basic"
}
]
},
{
"description": "Use F2 to Open WebStorm",
"manipulators": [
{
"from": {
"key_code": "f2"
},
"to": [
{
"shell_command": "open -a '/Users/oomusou/Applications/WebStorm.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Option + F2 to Open Android Studio",
"manipulators": [
{
"from": {
"key_code": "f2",
"modifiers": {
"mandatory": ["option"]
}
},
"to": [
{
"shell_command": "open -a '/Users/oomusou/Applications/Android Studio.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F2 to Increase Brightness",
"manipulators": [
{
"from": {
"key_code": "f2",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"consumer_key_code": "display_brightness_increment"
}
],
"type": "basic"
}
]
},
{
"description": "Use F3 to Open Web Converter",
"manipulators": [
{
"from": {
"key_code": "f3"
},
"to": [
{
"shell_command": "open -a '/Applications/WebP Converter.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F3 to Misson Control",
"manipulators": [
{
"from": {
"key_code": "f3",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"apple_vendor_keyboard_key_code": "mission_control"
}
],
"type": "basic"
}
]
},
{
"description": "Use F4 to Open iTerm",
"manipulators": [
{
"from": {
"key_code": "f4"
},
"to": [
{
"shell_command": "open -a '/Applications/iTerm.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F4 to Zoom",
"manipulators": [
{
"from": {
"key_code": "f4",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"key_code": "8",
"modifiers": ["command", "option"]
}
],
"type": "basic"
}
]
},
{
"description": "Use F5 to Open Typora",
"manipulators": [
{
"from": {
"key_code": "f5"
},
"to": [
{
"shell_command": "open -a '/Applications/Typora.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F5 to Capture Text",
"manipulators": [
{
"from": {
"key_code": "f5",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"key_code": "1",
"modifiers": ["command", "shift"]
}
],
"type": "basic"
}
]
},
{
"description": "Use F6 to Open ForkLift",
"manipulators": [
{
"from": {
"key_code": "f6"
},
"to": [
{
"shell_command": "open -a '/Applications/setapp/ForkLift.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F6 to Capture Screen",
"manipulators": [
{
"from": {
"key_code": "f6",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"key_code": "3",
"modifiers": ["command", "shift"]
}
],
"type": "basic"
}
]
},
{
"description": "Use F7 to Open Sublime Text",
"manipulators": [
{
"from": {
"key_code": "f7"
},
"to": [
{
"shell_command": "open -a '/Applications/Sublime Text.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F7 to Rewind",
"manipulators": [
{
"from": {
"key_code": "f7",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"consumer_key_code": "rewind"
}
],
"type": "basic"
}
]
},
{
"description": "Use F8 to Open MOJisho",
"manipulators": [
{
"from": {
"key_code": "f8"
},
"to": [
{
"shell_command": "open -a '/Applications/MOJisho.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F8 to Play/Pause",
"manipulators": [
{
"from": {
"key_code": "f8",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"consumer_key_code": "play_or_pause"
}
],
"type": "basic"
}
]
},
{
"description": "Use F9 to Open ChatGPT",
"manipulators": [
{
"from": {
"key_code": "f9"
},
"to": [
{
"shell_command": "open -a '/Applications/ChatGPT.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F9 to Fast Foward",
"manipulators": [
{
"from": {
"key_code": "f9",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"consumer_key_code": "fast_forward"
}
],
"type": "basic"
}
]
},
{
"description": "Use F10 to Open Gitfox",
"manipulators": [
{
"from": {
"key_code": "f10"
},
"to": [
{
"shell_command": "open -a '/Applications/setapp/Gitfox.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F10 to Mute",
"manipulators": [
{
"from": {
"key_code": "f10",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"consumer_key_code": "mute"
}
],
"type": "basic"
}
]
},
{
"description": "Use F11 to Open Chrome",
"manipulators": [
{
"from": {
"key_code": "f11"
},
"to": [
{
"shell_command": "open -a '/Applications/Google Chrome.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F11 to Decrease Volumn",
"manipulators": [
{
"from": {
"key_code": "f10",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"consumer_key_code": "volume_decrement"
}
],
"type": "basic"
}
]
},
{
"description": "Use F12 to Open FireFox",
"manipulators": [
{
"from": {
"key_code": "f12"
},
"to": [
{
"shell_command": "open -a '/Applications/Firefox.app'"
}
],
"type": "basic"
}
]
},
{
"description": "Use Command + F12 to Increase Volumn",
"manipulators": [
{
"from": {
"key_code": "f10",
"modifiers": {
"mandatory": ["command"]
}
},
"to": [
{
"consumer_key_code": "volume_increment"
}
],
"type": "basic"
}
]
}
]
},
"devices": [
{
"disable_built_in_keyboard_if_exists": false,
"fn_function_keys": [],
"identifiers": {
"is_keyboard": true,
"is_pointing_device": false,
"product_id": 0,
"vendor_id": 0
},
"ignore": false,
"manipulate_caps_lock_led": true,
"simple_modifications": [],
"treat_as_built_in_keyboard": false
},
{
"disable_built_in_keyboard_if_exists": false,
"fn_function_keys": [],
"identifiers": {
"is_keyboard": false,
"is_pointing_device": true,
"product_id": 0,
"vendor_id": 0
},
"ignore": true,
"manipulate_caps_lock_led": false,
"simple_modifications": [],
"treat_as_built_in_keyboard": false
}
],
"name": "Default profile",
"parameters": {
"delay_milliseconds_before_open_device": 1000
},
"selected": true,
"simple_modifications": [],
"virtual_hid_keyboard": {
"country_code": 0,
"indicate_sticky_modifier_keys_state": true,
"mouse_key_xy_scale": 100
}
}
]
}
karabiner.json
位於 /Users/oomosou/.config/karabiner
目錄下。
Shell Command
Line 19
"rules": [
- rules:若要使用 Complex Modification,要統一寫在
rules
下
Line 20
{
"description": "Use F1 to Open Safari",
"manipulators": [
{
"from": {
"key_code": "f1"
},
"to": [
{
"shell_command": "open -a '/Applications/Safari.app'"
}
],
"type": "basic"
}
]
},
- from.key_code : 設定
Fn
- to.shell_command : 設定
Fn
要開啟的 app
Shortcut
Line 184
{
"description": "Use Command + F5 to Capture Text",
"manipulators": [
{
"from": {
"key_code": "f5",
"modifiers": {
"mandatory": [
"command"
]
}
},
"to": [
{
"key_code": "1",
"modifiers": [
"command",
"shift"
]
}
],
"type": "basic"
}
]
},
- manipulators.from.key_code:設定
Fn
鍵 - manipulators.to.key_code:設定 shortcut 主鍵
- manipulators.to.modifiers:設定 shortcut 的輔助鍵
- manipulators.type:shortcut 一定要設定為
basic
System Function
Line 36
{
"description": "Use Command + F1 to Decrease Brightness",
"manipulators": [
{
"from": {
"key_code": "f1",
"modifiers": {
"mandatory": [
"command"
]
}
},
"to": [
{
"consumer_key_code": "display_brightness_decrement"
}
],
"type": "basic"
}
]
}
- manipulators.from.key_code:設定
Fn
- manipulators.from.modifiers.mandatory:設定
Fn
的 modifier key - manipulators.to.consumer_key_code:設定系統功能
Conclusion
- 事實上 Karabiner-Elements 的功能非常複雜,本文只使用了最基本的重新定義
Fn
鍵 Fn
鍵若要執行 shell command 可使用fn_function_keys
,亦可使用 Complex Modification,本文統一使用 Complex ModificationF6
與F7
因為很少用到原本功能,因此重新定義成 Capture Text 與 SleepF3
與F4
目前能維持原本的 Mission Control 的 Spotlight,若將來有其他需求,亦可率先選擇這兩個按鍵自行定義- 當
Fn
鍵可搭配⌘
後,則可同時保留切換 app
與原本功能
,若有更多的 app 要切換,可搭配⌥
,如此實用性已經可超越 Touch Bar