0
0

ホームポジションを絶対維持するためのKarabiner設定

Posted at

はじめに

VS CodeやNotionなどのアプリを操作する際に、

  • カーソルキーを使うショートカット(文字移動や文字選択等)
  • Backspaceを使うショートカット(文字削除、単語削除、行削除)
  • ESCキー

を押すたびにホームポジションから手を動かさなくて良いように、karabinerで別途ショートカットを割り当てています。本記事の設定をすると、アプリショートカット使用時に、カーソルキー/Backspace/ESCに手を伸ばさなくてよくなるので、ホームポジションを常に維持できます。

事前準備

Karabiner-Elementsをインストール
https://karabiner-elements.pqrs.org/

Karabiner設定方法

control + p control + n control + f control + bbackspacecontrol + hesccontrol + [ でも入力できるようにするというポリシーで設定します。

カーソルキーを使うショートカットの設定

デフォルトキー                       karabinerで割り当てるショートカット        備考                                よく使うもの
control + f Macのデフォルトでも設定されているが、viのinsert mode中に使えないなど一部アプリで使用できない場合があるので、上書き設定
control + b 同上
control + p 同上
control + n 同上
shift + → control + shift + f どのアプリでも基本的に「次の文字を選択」に設定されている
shift + ← control + shift + b どのアプリでも基本的に「前の文字を選択」に設定されている
shift + ↑ control + shift + p どのアプリでも基本的に「上の行まで選択」に設定されている
shift + ↓ control + shift + n どのアプリでも基本的に「下の行まで選択」に設定されている
option + → control + option + f どのアプリでも基本的に「次の単語に移動」に設定されている
option + ← control + option + b どのアプリでも基本的に「前の単語に移動」に設定されている
option + ↑ control + option + p アプリにより動作が違う
option + ↓ control + option + n アプリにより動作が違う
command + → - 以下理由により未設定 ・ control + command + fがMacのフルスクリーン化のショートカットとかぶる ・ アプリショートカットで command + → は行末に移動に設定されいることが多く、control + E で代替可能なため
command + ← - 以下理由により未設定 ・対となる command + →にショートカットを設定しないため ・アプリショートカットで command + ← は行頭に移動に設定されいることが多く、control + Aで代替可能なため
command + ↑ control + command + p アプリにより動作が違う
command + ↓ control + command + n アプリにより動作が違う
shift + option + → control + shift + option + f どのアプリでも基本的に「次の単語を選択」に設定されている
shift + option + ← control + shift + option + b どのアプリでも基本的に「前の単語を選択」に設定されている
shift + option + ↑ control + shift + option + p アプリにより動作が違う
shift + option + ↓ control + shift + option + n アプリにより動作が違う
shift + command + → control + shift + command + f どのアプリでも基本的に「行末まで選択」に設定されている
shift + command + ← control + shift + command + b どのアプリでも基本的に「行頭まで選択」に設定されている
shift + command + ↑ control + shift + command + p アプリにより動作が違う
shift + command + ↓ control + shift + command + n アプリにより動作が違う
option + command + → control + option + command + f アプリにより動作が違う
option + command + ← control + option + command + b アプリにより動作が違う
option + command + ↑ control + option + command + p アプリにより動作が違う
option + command + ↓ control + option + command + n アプリにより動作が違う

Backspaceを使うショートカットの設定

デフォルトキー                       karabinerで割り当てるショートカット        備考                                よく使うもの
backspace control + h
option + backspace option + control + h どのアプリでも基本的に「単語削除」に設定されている
command + backspace command + control + h どのアプリでも基本的に「行削除」に設定されている

ESCの設定

デフォルトキー                       karabinerで割り当てるショートカット        備考                                よく使うもの
ESC control + [ viでESCとキーコードが同じため、Ctrl-[を設定

設定手順

  1. ~/.config/karabiner/assets/complex_modifications に下記ファイルを配置

    cursor.json
    {
      "title": "Cursor",
      "rules": [
        {
          "description": "Modifier Keys (except control) + control+f/control+b/control+p/control+n to Modifier Keys (except control) + →/←/↑/↓",
          "manipulators": [
            {
              "type": "basic",
              "from": {
                "key_code": "f",
                "modifiers": {
                  "mandatory": ["control"]
                }
              },
              "to": [
                {
                  "key_code": "right_arrow"
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "b",
                "modifiers": {
                  "mandatory": ["control"]
                }
              },
              "to": [
                {
                  "key_code": "left_arrow"
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "p",
                "modifiers": {
                  "mandatory": ["control"]
                }
              },
              "to": [
                {
                  "key_code": "up_arrow"
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "n",
                "modifiers": {
                  "mandatory": ["control"]
                }
              },
              "to": [
                {
                  "key_code": "down_arrow"
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "f",
                "modifiers": {
                  "mandatory": ["control", "shift"]
                }
              },
              "to": [
                {
                  "key_code": "right_arrow",
                  "modifiers": ["shift"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "b",
                "modifiers": {
                  "mandatory": ["control", "shift"]
                }
              },
              "to": [
                {
                  "key_code": "left_arrow",
                  "modifiers": ["shift"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "p",
                "modifiers": {
                  "mandatory": ["control", "shift"]
                }
              },
              "to": [
                {
                  "key_code": "up_arrow",
                  "modifiers": ["shift"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "n",
                "modifiers": {
                  "mandatory": ["control", "shift"]
                }
              },
              "to": [
                {
                  "key_code": "down_arrow",
                  "modifiers": ["shift"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "f",
                "modifiers": {
                  "mandatory": ["control", "option"]
                }
              },
              "to": [
                {
                  "key_code": "right_arrow",
                  "modifiers": ["option"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "b",
                "modifiers": {
                  "mandatory": ["control", "option"]
                }
              },
              "to": [
                {
                  "key_code": "left_arrow",
                  "modifiers": ["option"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "p",
                "modifiers": {
                  "mandatory": ["control", "option"]
                }
              },
              "to": [
                {
                  "key_code": "up_arrow",
                  "modifiers": ["option"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "n",
                "modifiers": {
                  "mandatory": ["control", "option"]
                }
              },
              "to": [
                {
                  "key_code": "down_arrow",
                  "modifiers": ["option"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "p",
                "modifiers": {
                  "mandatory": ["control", "command"]
                }
              },
              "to": [
                {
                  "key_code": "up_arrow",
                  "modifiers": ["command"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "n",
                "modifiers": {
                  "mandatory": ["control", "command"]
                }
              },
              "to": [
                {
                  "key_code": "down_arrow",
                  "modifiers": ["command"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "f",
                "modifiers": {
                  "mandatory": ["control", "shift", "option"]
                }
              },
              "to": [
                {
                  "key_code": "right_arrow",
                  "modifiers": ["shift", "option"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "b",
                "modifiers": {
                  "mandatory": ["control", "shift", "option"]
                }
              },
              "to": [
                {
                  "key_code": "left_arrow",
                  "modifiers": ["shift", "option"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "p",
                "modifiers": {
                  "mandatory": ["control", "shift", "option"]
                }
              },
              "to": [
                {
                  "key_code": "up_arrow",
                  "modifiers": ["shift", "option"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "n",
                "modifiers": {
                  "mandatory": ["control", "shift", "option"]
                }
              },
              "to": [
                {
                  "key_code": "down_arrow",
                  "modifiers": ["shift", "option"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "f",
                "modifiers": {
                  "mandatory": ["control", "shift", "command"]
                }
              },
              "to": [
                {
                  "key_code": "right_arrow",
                  "modifiers": ["shift", "command"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "b",
                "modifiers": {
                  "mandatory": ["control", "shift", "command"]
                }
              },
              "to": [
                {
                  "key_code": "left_arrow",
                  "modifiers": ["shift", "command"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "p",
                "modifiers": {
                  "mandatory": ["control", "shift", "command"]
                }
              },
              "to": [
                {
                  "key_code": "up_arrow",
                  "modifiers": ["shift", "command"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "n",
                "modifiers": {
                  "mandatory": ["control", "shift", "command"]
                }
              },
              "to": [
                {
                  "key_code": "down_arrow",
                  "modifiers": ["shift", "command"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "f",
                "modifiers": {
                  "mandatory": ["control", "option", "command"]
                }
              },
              "to": [
                {
                  "key_code": "right_arrow",
                  "modifiers": ["option", "command"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "b",
                "modifiers": {
                  "mandatory": ["control", "option", "command"]
                }
              },
              "to": [
                {
                  "key_code": "left_arrow",
                  "modifiers": ["option", "command"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "p",
                "modifiers": {
                  "mandatory": ["control", "option", "command"]
                }
              },
              "to": [
                {
                  "key_code": "up_arrow",
                  "modifiers": ["option", "command"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "n",
                "modifiers": {
                  "mandatory": ["control", "option", "command"]
                }
              },
              "to": [
                {
                  "key_code": "down_arrow",
                  "modifiers": ["option", "command"]
                }
              ]
            }
          ]
        }
      ]
    }
    
    backspace.json
    {
      "title": "Backspace",
      "rules": [
        {
          "description": "option/command + backspace to option/command + control+h",
          "manipulators": [
            {
              "type": "basic",
              "from": {
                "key_code": "h",
                "modifiers": {
                  "mandatory": ["control"]
                }
              },
              "to": [
                {
                  "key_code": "delete_or_backspace"
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "h",
                "modifiers": {
                  "mandatory": ["control", "option"]
                }
              },
              "to": [
                {
                  "key_code": "delete_or_backspace",
                  "modifiers": ["option"]
                }
              ]
            },
            {
              "type": "basic",
              "from": {
                "key_code": "h",
                "modifiers": {
                  "mandatory": ["control", "command"]
                }
              },
              "to": [
                {
                  "key_code": "delete_or_backspace",
                  "modifiers": ["command"]
                }
              ]
            }
          ]
        }
      ]
    }
    
    esc.json
    {
      "title": "Esc",
      "rules": [
        {
          "description": "control+[ to escape",
          "manipulators": [
            {
              "type": "basic",
              "from": {
                "key_code": "close_bracket",
                "modifiers": {
                  "mandatory": ["control"]
                }
              },
              "to": [
                {
                  "key_code": "escape"
                }
              ]
            }
          ]
        }
      ]
    }
    
     
  2. KarabinerのSettingsを開く

  3. Complex Modifications > Add predefined rule

    Untitled.png

  4. 「Backspace」, 「Cursor」, 「Esc」のルールをすべてEnableにする

    Untitled2.png

  5. Complex Modificationsに3つルールが追加されていれば設定完了

    Untitled3.png

設定したショートカットの修飾キーの押し方

修飾キーの組み合わせごとの指使いは以下の通りです。

  • control(左小指)
  • control(左薬指)+ shift(左小指)
  • control(左小指)+ option(左薬指)
  • control(左薬指) + shift(左小指)+ option(左親指)
  • control(左小指) + command(左親指)
  • control(左薬指) + shift(左小指) + command(左親指)

おわりに

修飾キーの押し方に慣れが必要ですが、慣れればどんなショートカットもホームポジションを崩さずに押せて開発効率が爆上がりするのでおすすめです!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0