AI & ML
Using Ctrl+Enter to Submit in OpenCode and Enter for New Lines
loach Dev.to (EN Zone)
1 views
Another OpenCode behavior I wanted to change was message submission.
By default, pressing Enter submits the current prompt. If you are used to chat tools where Enter inserts a new line and Ctrl + Enter sends, this makes accidental submissions easy.
My preferred setup is:
Enter: insert a new line
Ctrl + Enter: submit the prompt
OpenCode configuration
Edit your OpenCode configuration file and update the keybindings:
{
"keybinds": {
"app_exit": "ctrl+d,<leader>q",
"input_submit": "ctrl+return",
"input_newline": "shift+return,return,alt+return,ctrl+j"
}
}
This tells OpenCode to treat normal Enter-style keys as new lines and reserve Ctrl + Enter for submission.
The terminal may need configuration too
There is one important detail: some terminals do not send a distinct key sequence for Ctrl + Enter by default.
In that case, OpenCode cannot distinguish it from plain Enter.
For Windows Terminal, you can define a custom sequence:
"actions": [
{
"command": {
"action": "sendInput",
"input": "\u001b[13;5u"
},
"id": "User.sendInput.CtrlEnterCustom"
}
]
Then bind Ctrl + Enter to that action in the terminal settings.
The exact terminal configuration can vary, but the principle is the same: the terminal must send a distinguishable sequence before OpenCode can bind it separately.
Why this improves the workflow
Long prompts often contain code blocks, lists, and multiple paragraphs.
Making Enter safe for editing removes the pressure to finish the whole prompt on one line and reduces accidental sends.
It also makes OpenCode behave more like many chat and editor-oriented interfaces.
Closing thoughts
Keybindings are a small detail, but AI coding tools are used interactively for long periods. Small interaction problems become surprisingly expensive when repeated all day.
For me, separating newline and submit made OpenCode much more comfortable to use.
Read original: https://dev.to/loach2009/using-ctrlenter-to-submit-in-opencode-and-enter-for-new-lines-2065
Related
From Code Reviewer to Agent Manager: Lessons from 30 Days of AI-Generated Software
AI & ML
0
Dev.to (EN Zone)
7 Best Email MCP Servers and APIs for AI Agents (2026)
AI & ML
1
Dev.to (EN Zone)
Preventing Accidental OpenCode Exits with Ctrl+C
AI & ML
0
Dev.to (EN Zone)
Is There a Safer Wallet for AI Agents? Here's the Architecture I found that might work.
AI & ML
2
DEV Community
Comments0
No comments yet — be the first