2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Caps Lock+hjkl を←↓↑→にする(MacOS)

Last updated at Posted at 2024-03-14

自分用のメモ記事ですが、参考になる人がいれば、と記事にしておきます。

Mac環境の話です。Caps Lockに Ctrl キーを割り当て、Ctrl+hjkl でカーソル移動できるようにしていましたが、Ctrl+kと言うキー割り当てが Visual Studio と重複してしまって困っていました。

最初はCaps Lock を Ctrl に割り当てず、そのまま Caps Lock として扱いながら、hjkl同時押しの場合はカーソル移動として設定してみました。
これは意外と簡単にできるのですが、押したキーを離すと Caps Lock の On/Off も動作してしまっていました。hjkl を同時押しした時だけは On/Off が動作しないようにする設定がわかったのでメモしておきます。

Karabiner-Elements にカスタム設定を入れます。
Settings を開き、Complex Modifications をクリック。Add your own rule ボタンをクリックして表示されたダイアログの中の json を全て消して、以下に書き換えます。

{
    "description": "Caps Lock hjkl to Arrow",
    "manipulators": [
        {
            "from": {
                "key_code": "caps_lock",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "set_variable": {
                        "name": "caps_lock pressed",
                        "value": 1
                    }
                }
            ],
            "to_after_key_up": [
                {
                    "set_variable": {
                        "name": "caps_lock pressed",
                        "value": 0
                    }
                }
            ],
            "to_if_alone": [
                {
                    "key_code": "caps_lock"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "h",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "left_arrow"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "j",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "down_arrow"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "k",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "up_arrow"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "name": "caps_lock pressed",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "l",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "right_arrow"
                }
            ],
            "type": "basic"
        }
    ]
}

この json は次のリンク先の情報ほぼそのままです。キーをwsadからhjklに変えただけです。
https://github.com/pqrs-org/Karabiner-Elements/issues/3120

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?