LoginSignup
3
3

More than 3 years have passed since last update.

Karabiner-Elementsを使ってセミコロンエンターを実現する

Posted at

はじめに

Mac OSXでキーバインドを変更できるツールKarabiner-Elementsを使っている人が多いと思う。
実は単純なキーのリマップだけでなく、少し複雑な処理も自分でjsonファイルを書くことで実現できる。

この記事ではセミコロンをエンターにリマップする方法を紹介する。セミコロン;は右手小指のホームポジションにあるキーだが、そこをenterキーに変えるとめちゃくちゃ作業が捗る。
エンターキーを押す頻度は本当に高いが、そのキーが近くにあると本当に楽になるのでぜひ一度試してほしい。試せばわかる。

この時、単純に;をエンターキーにリマップしてしまうと、セミコロンを打つ手段がなくなってしまう。ctrl + ;を打つと;を打てるようにする。

ちなみにこの記事の内容は Karabiner-Elements 1.27.0 で動作確認している。

手順

Karabiner-Elementsの"complex modifications"という機能を使う。

手順1: キーリマップを定義したJSONファイルの準備

以下のようなjsonファイルを ~/.config/karabiner/assets/complex_modificationsディレクトリに配置する

semicolon_enter.json
{
  "title": "semicolon to enter",
  "rules":
  [
    {
      "description": "semicolon to enter",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "semicolon",
            "modifiers": {
              "mandatory": [
                "control"
              ]
            }
          },
          "to": [
            {
              "key_code": "semicolon"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "slash",
            "modifiers": {
              "mandatory": [
                "control"
              ]
            }
          },
          "to": [
            {
              "key_code": "semicolon"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "semicolon",
            "modifiers": {
              "optional": [
                "caps_lock"
              ]
            }
          },
          "to": [
            {
              "key_code": "return_or_enter"
            }
          ]
        }
      ]
    }
  ]
}

書式は公式ドキュメントにも書いてあるが、上記のjsonファイルを見れば何をどうマップしているのかだいたい理解できると思う。
(ここではctrl + /;にマップしている。これは自分の趣味)

手順2: Karabiner-Elementsにロードする

"Complex modifications"のタブから"Add rule"をクリック

image.png

先ほど追加したルール(semicolon to enter)の"Enable"をクリック

image.png

以上で完了。すぐに変更が反映されるはず。

参照

3
3
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
3
3