(´ワ`)

主に技術系備忘録、たまに日記。

Alfredとかでキーバインドを⌘+Spaceとしたときに英数も一緒に送信しちゃう

タイトルママ。

僕は普段Alfredのキーバインドを⌘+Spaceにしています。
基本的にAlfredで検索する内容は英語ばかりなので、起動したときはすぐに英数の状態になっていてほしいですね。
素早い操作に慣れてなにも確認せずに起動した瞬間にタイピングして「かな」だったときはとても苛立ちが...ピキィ!!

Karabiner-Elementsで解決

いつもどおりこういうバインディング的な作業はKarabiner-Elementsにお願いしてます。
今回は⌘+Spaceのキーバインドに合わせて英数が送信される設定に加えてCtrl+Spaceもついでに加えたルールファイルを作成しました。

{
  "title": "Alfred用ルール",
  "rules": [
    {
      "description": "Command + Spaceで起動時に英数キーを送信する(Alfred用)",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "spacebar",
            "modifiers": {
              "mandatory": [
                "command"
              ]
            }
          },
          "to": [
            {
              "key_code": "spacebar",
              "modifiers": [ 
                "command"
              ]
            },
            {
              "key_code": "japanese_eisuu"
            }
          ]
        }
      ]
    },
    {
      "description": "Control + Spaceで起動時に英数キーを送信する(Alfred用)",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "spacebar",
            "modifiers": {
              "mandatory": [
                "control"
              ]
            }
          },
          "to": [
            {
              "key_code": "spacebar",
              "modifiers": [ 
                "control"
              ]
            },
            {
              "key_code": "japanese_eisuu"
            }
          ]
        }
      ]
    }
  ]
}

これを~/.config/karabiner/assets/complex_modifications配下に好きな名前でjsonファイルとして保存しておくと勝手に追加されてます。

f:id:nnsnico:20180907013114p:plain