Mac デスクトップ版 ChatGPT Enterで誤送信を防ぐ

2025/01/25に公開

課題

ChatGPTのチャット画面はEnterの単打で送信されてしまいます。ブラウザ版では機能拡張でCtrl+Enterに再割り当てすることができましたが、デスクトップ版(スタンドアロンアプリ)ではカスタマイズができません。

解決策

Karabiner-elementsを使います。Complex Modificationsで新たなルールを作成し、以下のJsonをコピペします。

{
    "description": "ChatGPT Enter key behavior",
    "manipulators": [
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "com.openai.chat"
                    ],
                    "type": "frontmost_application_if"
                }
            ],
            "from": {
                "key_code": "return_or_enter",
                "modifiers": {}
            },
            "to": [
                {
                    "key_code": "return_or_enter",
                    "modifiers": ["shift"]
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "com.openai.chat"
                    ],
                    "type": "frontmost_application_if"
                }
            ],
            "from": {
                "key_code": "return_or_enter",
                "modifiers": { "mandatory": ["control"] }
            },
            "to": [{ "key_code": "return_or_enter" }],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "com.openai.chat"
                    ],
                    "type": "frontmost_application_if"
                }
            ],
            "from": {
                "key_code": "return_or_enter",
                "modifiers": { "mandatory": ["command"] }
            },
            "to": [{ "key_code": "return_or_enter" }],
            "type": "basic"
        }
    ]
}

解説

ChatGPTの振る舞いが、

  • Enterで送信
  • Shift+Enterで改行

なので、

  1. EnterをShift+Enterに割り当て
  2. Ctrl+EnterをEnterに割り当て
  3. Cmd+EnterをEnterに割り当て

というルールを設定することで、Enterで改行、Ctrl or Cmd + Enterで送信するように振る舞いを修正しています。

Discussion