2021年5月5日水曜日

macOS 10.15.7 + karabiner element 13.4.0 + Microsoft Outlook for Mac 16.48 (21401102) の新規メール作成ウィンドウのテキスト入力領域でCtrl-A/Ctrl-Eが効かない

macOS 10.15.7 + karabiner element 13.4.0 + Microsoft Outlook for Mac 16.48 (21401102) の新規メール作成ウィンドウのテキスト入力領域で、Ctrl-A/Ctrl-Eが動作しません。もちろん、以下のように標準的なEmacsふうのキー操作をできるようにするjsonファイルは読み込んでいます。


検索エンジンで調べてみても情報があまりなく困っていたときに、以下のblogのページを見つけました。
Karabiner-Elementsを使って特定のアプリでショートカットキーを上書する
ここでは、macOSでのMicrosoftのアプリケーションで、Ctrl-P/N/B/F/A/Eなどを使えるようにする方法が紹介されています。そこで、思いたって、ここで紹介されているjsonファイルを標準的なEmacsふうキー操作のjsonファイルの後に読み込んでみました。


すると、Ctrl-A/Ctrl-Eが動くようになりました。ただ、このままだと他のMicrosoftのアプリケーションでCtrl-A/Ctrl-Eの動作がおかしくなるようです。なので

"^com\\.microsoft\\."

の部分を

"^com\\.microsoft\\.Outlook"

に、そしてCtrl-A/EをそれぞれCommand+Left_Arrow/Right_Arrowにマップするように変更しました。上記の記事がなくなってしまうと困るので、以下に、変更したものを再掲します。

{

  "title": "emacs keybind in MS apps",

  "rules":

  [

    {

      "description": "emacs keybind in skype & office",

      "manipulators": [

        {

          "conditions": [

            {

              "bundle_identifiers": [

                "^com\\.skype\\.skype$",

                "^com\\.microsoft\\.Outlook"

              ],

              "type": "frontmost_application_if"

            }

          ],

          "from": {

            "key_code": "h",

            "modifiers": {

              "mandatory": [

                "control"

              ]

            }

          },

          "to": [

            {

              "key_code": "delete_or_backspace"

            }

          ],

          "type": "basic"

        },

        {

          "conditions": [

            {

              "bundle_identifiers": [

                "^com\\.microsoft\\.Outlook"

              ],

              "type": "frontmost_application_if"

            }

          ],

          "from": {

            "key_code": "d",

            "modifiers": {

              "mandatory": [

                "control"

              ]

            }

          },

          "to": [

            {

              "key_code": "delete_forward"

            }

          ],

          "type": "basic"

        },

        {

          "conditions": [

            {

              "bundle_identifiers": [

                "^com\\.microsoft\\.Outlook"

              ],

              "type": "frontmost_application_if"

            }

          ],

          "from": {

            "key_code": "f",

            "modifiers": {

              "mandatory": [

                "control"

              ]

            }

          },

          "to": [

            {

              "key_code": "right_arrow"

            }

          ],

          "type": "basic"

        },

        {

          "conditions": [

            {

              "bundle_identifiers": [

                "^com\\.microsoft\\.Outlook"

              ],

              "type": "frontmost_application_if"

            }

          ],

          "from": {

            "key_code": "b",

            "modifiers": {

              "mandatory": [

                "control"

              ]

            }

          },

          "to": [

            {

              "key_code": "left_arrow"

            }

          ],

          "type": "basic"

        },

        {

          "conditions": [

            {

              "bundle_identifiers": [

                "^com\\.microsoft\\.Outlook"

              ],

              "type": "frontmost_application_if"

            }

          ],

          "from": {

            "key_code": "p",

            "modifiers": {

              "mandatory": [

                "control"

              ]

            }

          },

          "to": [

            {

              "key_code": "up_arrow"

            }

          ],

          "type": "basic"

        },

        {

          "conditions": [

            {

              "bundle_identifiers": [

                "^com\\.microsoft\\.Outlook"

              ],

              "type": "frontmost_application_if"

            }

          ],

          "from": {

            "key_code": "n",

            "modifiers": {

              "mandatory": [

                "control"

              ]

            }

          },

          "to": [

            {

              "key_code": "down_arrow"

            }

          ],

          "type": "basic"

        },

        {

          "conditions": [

            {

              "bundle_identifiers": [

                "^com\\.microsoft\\.Outlook"

              ],

              "type": "frontmost_application_if"

            }

          ],

          "from": {

            "key_code": "e",

            "modifiers": {

              "mandatory": [

                "control"

              ]

            }

          },

          "to": [

            {

              "key_code": "right_arrow",

              "modifiers": [

                "left_command"

              ]

            }

          ],

          "type": "basic"

        },

        {

          "conditions": [

            {

              "bundle_identifiers": [

                "^com\\.microsoft\\.Outlook"

              ],

              "type": "frontmost_application_if"

            }

          ],

          "from": {

            "key_code": "a",

            "modifiers": {

              "mandatory": [

                "control"

              ]

            }

          },

          "to": [

            {

              "key_code": "left_arrow" ,

              "modifiers": [

                "left_command"

              ]

            }

          ],

          "type": "basic"

        }

      ]

    }

  ]

}