Add Shift+Enter to OpenCode in Windows Terminal

Add Shift+Enter to OpenCode in Windows Terminal

The open source AI coding agent Open Code is becoming my go-to editor for AI agents. What's not to love? I can add both OpenAI and GitHub Copilot as providers. Working in the terminal can be a bit different than working in a web browser, especially when inserting new lines. In Windows Terminal, I have to use Ctrl+Enter for a newline. Let's face it: it's just not muscle memory for me. So what can we do?

Key Binding

We can add the following key binding:

"actions": 
    [
        {
            "command": 
            {
                "action": "sendInput",
                "input": "\u001b[13;2u"
            },
            "id": "User.sendInput.8882FD6D"
        }
    ]

This sends the Shift+Enter key sequence in the kitty keyboard protocol format to whatever application is running in your terminal, allowing applications like Neovim that support the protocol to distinguish Shift+Enter from a plain Enter.

To be honest, I had no idea what the kitty keyboard protocol was, but Windows Terminal has support for it. According to the developer, it solves all sorts of problems with modifiers (like Shift, in our case).

AI me

Let your AI fix the problem:

Please read https://keestalkstech.com/adding-shiftenter-for-opencode-on-windows-terminal.md and add the ctrl+enter feature to the settings of my Windows Terminal.