デフォルトのKarabinaの設定ファイルは、「~/.config/karabiner/karabiner.json」 に保存されます。
descriptionを増やしていきます。
{
"description": "CCCCCCCCCCCCCCCC",
"manipulators": [
{ "type": "basic",
"from": {
(略)
]
}
]
},
{
"description": "DDDDDDDDDDDDDDDDDD",
"manipulators": [
{ "type": "basic",
"from": {
(略)
]
}
]
},
JSONファイルを新規に作成し、「~/.config/karabiner/assets/complex_modifications/」以下に置いて、
そこから設定画面の「Complex Modifications - Add rule」で必要なdescription設定のみ適用していく方もあります。
ファイル名は拡張子 .json になっていれば、名前は何でも大丈夫のはずですが、ファイル名を数字にしないと認識されないときがあるようです。
「Complex Modifications - Import more rules from the Internet(open a web browser)」で取得した設定ファイルも、同じ場所に保存されます。
titleがある以下のフォーマットになります。
{
"title": "XXXXXXXXXXXXXXXXX",
"rules": [
{
"description": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"manipulators": [
{
"type": "basic",
"from": {
(略)
}
]
},
{
"description": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
"manipulators": [
{
"type": "basic",
"from": {
}
(略)
]
}
]
}
「~/.config/karabiner/karabiner.json」は設定後にすぐに反映されます。
「~/.config/karabiner/assets/complex_modifications」は、
「Complex Modifications」で対象のルールを削除して、再度ルールを追加して、karabiner.jsonに登録する必要がります。
CaptLockとCtrlを交換するなどの設定ができます。
僕は利用していないので、説明は省略します。
Homeキー、Endキーがあるキーボードで、Windowsのように、homeキー、endキーが行先頭、行末に移動とする方法
Excelのセル内の改行を、WindowsのAltの位置に相当するCommand Enterで実現する
{
"description": "Excel command-enter to option-enter",
"manipulators": [
{ "type": "basic",
"from": {
"key_code": "return_or_enter",
"modifiers": { "mandatory": [ "left_command" ] }
},
"to": {
"key_code": "return_or_enter",
"modifiers": [ "left_option" ]
},
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.Excel$"
]
}
]
}
]
},
通常のHome/End設定よりも順位を先に置きましょう。
{
"title": "Excel Home and End",
"rules": [
{
"description": "Excel Home to Fn Left",
"manipulators": [
{
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.Excel$"
]
}
],
"type": "basic",
"from": {
"key_code": "home",
"modifiers": {
"optional": ["shift"]
}
},
"to": [
{
"key_code": "left_arrow",
"modifiers": "fn"
}
]
}
]
},
{
"description": "Excel End to Fn Right",
"manipulators": [
{
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.Excel$"
]
}
],
"type": "basic",
"from": {
"key_code": "end",
"modifiers": {
"optional": ["shift"]
}
},
"to": [
{
"key_code": "right_arrow",
"modifiers": "fn"
}
]
}
]
}
]
}
Excelだけではなく、Google Sheetもの場合
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.Excel$",
"^com\\.google\\.Chrome"
]
}
],
Karabiner-Elementsで複数キー設定やアプリごとにキーバインド設定をする | たんしおどっとねっと
"rules": [
{
"description": "TerminalまたはMacVimでESCあるいは^[を押したときに日本語入力を英数に切り替える。",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Terminal$",
"^org\\.vim\\.",
"^com\\.googlecode\\.iterm2$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "japanese_eisuu"
},
{
"key_code": "escape"
},
{
"key_code": "left_control"
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Terminal$",
"^org\\.vim\\.",
"^com\\.googlecode\\.iterm2$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "left_control",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_control"
}
],
"to_if_alone": [
{
"key_code": "japanese_eisuu"
},
{
"key_code": "escape"
},
{
"key_code": "left_control"
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Terminal$",
"^org\\.vim\\.",
"^com\\.googlecode\\.iterm2$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "escape",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "japanese_eisuu"
},
{
"key_code": "escape"
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Terminal$",
"^org\\.vim\\.",
"^com\\.googlecode\\.iterm2$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "open_bracket",
"modifiers": {
"mandatory": [
"left_control"
]
}
},
"to": [
{
"key_code": "japanese_eisuu"
},
{
"key_code": "escape"
}
],
"type": "basic"
}
]
},
Karabiner-Elements で特定のアプリにだけキーバインドを変更する - モノラルログ
~/.config/karabiner/assets/complex_modifications/browser.json
{
"title": "browser",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.apple\\.Safari",
"^com\\.google\\.Chrome",
"^com\\.vivaldi\\.Vivaldi"
]
}
],
"rules": [
{
"description": "F5 to reload",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "f5"
},
"to": [
{
"key_code": "r",
"modifiers": ["command"]
}
]
}
]
}
]
}
{
"description": "コマンドキーを単体で押したときに、英数・かなキーを送信する。(左コマンドキーは英数、右コマンドキーはかな)",
"manipulators": [
{
"from": {
"key_code": "left_command",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_command"
}
],
"to_if_alone": [
{
"key_code": "japanese_eisuu"
}
],
"type": "basic"
},
{
"from": {
"key_code": "right_command",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "right_command"
}
],
"to_if_alone": [
{
"key_code": "japanese_kana"
}
],
"type": "basic"
}
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "caps_lock"
},
"to": [
{
"key_code": "escape"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.jetbrains\\.intellij$",
"^com\\.microsoft\\.VSCode$"
]
}
],
"description": "caps_lock to escape if intellij"
}
{
"type": "basic",
"from": {
"key_code": "caps_lock"
},
"to": [
{
"key_code": "left_command"
}
],
"conditions": [
{
"type": "frontmost_application_unless",
"bundle_identifiers": [
"^com\\.jetbrains\\.intellij$",
"^com\\.microsoft\\.VSCode$"
]
}
],
"description": "caps_lock to left_command unless intellij"
},
MacBookでキー配列(US・JIS)を切り替える方法 | ENHANCE
Macbookの内蔵キーボードと外部キーボードのキー配列が異なる場合、
Karabinaのメニューバーから、キーボードの配列を設定する方法です。
「Profile」タブで、「JP」と「US」があります。
「+ Add profile」をクリックして、「JP 2」と「US 2」を作ります。
プロファイルを選択したまま、次は「Virtual Keyboard」項目に移動し、
内蔵キーボードがJIS配列の場合「45」を入力、US配列の場合「0」を入力しEnterキーをタイプします。
【効率化】Macで超速タイピング!Karabinerの使い方とサンプルコード | 29歳からアーティストを目指してみる
| キー | プログラムに書く名称 | キーの種類 |
|---|---|---|
| esc | escape | key_code |
| タブ | tab | key_code |
| control | left_control | key_code |
| 左Shift | left_shift | key_code |
| CapsLock | caps_lock | key_code |
| option | left_option | key_code |
| 左command | left_command | key_code |
| 英数 | japanese_eisuu | key_code |
| スペース | spacebar | key_code |
| かな | japanese_kana | key_code |
| 右command | right_command | key_code |
| fn | keyboard_fn | apple_vendor_top_case_key_code |
| 左キー「←」 | left_arrow | key_code |
| 下キー「↓」 | down_arrow | key_code |
| 上キー「↑」 | up_arrow | key_code |
| 右キー「→」 | right_arrow | key_code |
| 右Shift | right_shift | key_code |
| エンター | return_or_enter | key_code |
| delete | delete_or_backspace | key_code |