claude-code - 💡(How to fix) Fix [BUG] Cannot swap Enter and Shift+Enter behaviors [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45223Fetched 2026-04-09 08:10:25
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×6commented ×1

enter: chat:newline partially works (inserts newline) but cannot suppress the built-in submit action. shift+enter: chat:submit has no effect — Shift+Enter continues to insert a newline as if the binding were not present.

Error Message

Error Messages/Logs

Root Cause

enter: chat:newline partially works (inserts newline) but cannot suppress the built-in submit action. shift+enter: chat:submit has no effect — Shift+Enter continues to insert a newline as if the binding were not present.

Code Example



---

"enter": "chat:newline",
"shift+enter": "chat:submit"
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

iTerm2, v2.1.96, keybindings for context: "Chat" to SWAP enter and shift+enter: enter: chat:newline and shift+enter: chat:submit in keybindings.json

Enter does newline but also submits, Shift+Enter does newline and doesn't submit.

What Should Happen?

Enter should insert newline and Shift+Enter should submit

Error Messages/Logs

Steps to Reproduce

Environment

  • Claude Code v2.1.96
  • macOS, iTerm2
  • No custom iTerm2 key bindings
  • "Report keys using CSI u" unchecked

Config (~/.claude/keybindings.json)

Added to the Chat context:

"enter": "chat:newline",
"shift+enter": "chat:submit"

Steps to Reproduce

  1. Launch Claude Code in iTerm2
  2. Type some text
  3. Press Enter

Expected

Newline inserted, message not submitted

Actual

Newline inserted AND message submitted (hardcoded submit fires alongside the custom binding)

  1. Type some text
  2. Press Shift+Enter

Expected

Message submitted

Actual

Newline inserted (default behavior, custom binding ignored)

Summary

enter: chat:newline partially works (inserts newline) but cannot suppress the built-in submit action. shift+enter: chat:submit has no effect — Shift+Enter continues to insert a newline as if the binding were not present.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.96

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

No response

extent analysis

TL;DR

The issue can be resolved by modifying the keybindings configuration to correctly override the default submit action for the Enter key and ensuring the Shift+Enter binding is properly recognized.

Guidance

  • Review the keybindings.json configuration to ensure that the enter and shift+enter bindings are correctly defined for the "Chat" context, and consider adding a binding to explicitly prevent the default submit action on Enter.
  • Verify that iTerm2 is configured to recognize and pass through the Shift+Enter key combination correctly, as some terminals may have issues with shifted key bindings.
  • Test the keybindings in a minimal setup to isolate if the issue is specific to the Claude Code integration or a more general iTerm2 configuration problem.
  • Consider checking the Claude Code documentation for any specific guidance on customizing keybindings, especially regarding submit and newline actions in the chat context.

Example

No specific code example can be provided without risking inaccuracies, but ensuring the keybindings.json is correctly formatted and placed is crucial. For instance, the provided configuration snippet seems correct, but its placement and the overall structure of the keybindings.json file should be double-checked.

Notes

The exact solution may depend on specifics of iTerm2's keybinding handling and how Claude Code interprets these bindings, which could introduce variability in how the bindings are applied.

Recommendation

Apply workaround: Modify the keybindings.json to include a binding that explicitly prevents the default submit action on Enter, and verify iTerm2's configuration for shifted keys, as this approach directly addresses the reported issue without requiring an upgrade or assuming specific version dependencies.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING