cmd+escape doesn't blur the input when typing in the Claude Code panel (webview swallows the key)

Resolved 💬 3 comments Opened Apr 24, 2026 by Kahvi1 Closed May 28, 2026

Prior reports

Prior reports of the same symptom that were auto-closed for inactivity without a fix or root-cause analysis: #26189 (closest match — macOS, sidebar mode, "Cmd+Esc keybinding fails in sidebar view mode") and #18266 (related — the focus-direction equivalent on Linux). This issue adds reproduction steps and root cause from inspecting the bundled webview.

Summary

The default keybinding cmd+escape → claude-vscode.blur (declared in the extension's package.json with when: !config.claudeCode.useTerminal && !editorTextFocus) does not fire when the user is actively typing in the Claude Code input. Pressing cmd+escape has no effect — focus stays in the input and subsequent keystrokes continue to be captured by it. The reverse direction (cmd+escape from the editor → claude-vscode.focus) works correctly.

Environment

  • VS Code: 1.117.0 (arm64)
  • OS: macOS (darwin 25.3.0)
  • Extension: anthropic.claude-code 2.1.119 (darwin-arm64)
  • Setting claudeCode.useTerminal: false (default)

Steps to reproduce

  1. Open any workspace; ensure the Claude Code sidebar is visible.
  2. Click into the Claude Code message input. Type a few characters.
  3. Press Cmd+Escape.

Expected

The input loses focus (per the extension's own claude-vscode.blur keybinding declared in package.json). VS Code's natural focus chain returns focus to the editor.

Actual

Nothing happens. The input retains focus and continues to receive keystrokes. claude-vscode.blur is never invoked.

Root cause (from inspection of the bundled webview)

webview/index.js contains multiple keydown handlers that call preventDefault() + stopPropagation() (and in some cases stopImmediatePropagation()) on e.key === "Escape". Several of these handlers do not filter on e.metaKey / e.ctrlKey, so they swallow cmd+escape along with plain escape. Because the event never bubbles out of the iframe, VS Code's keybinding service never sees it and the cmd+escape → claude-vscode.blur binding never fires.

A few handlers in the same file already guard with !e.metaKey && !e.ctrlKey (e.g. r.key === "Escape" && !r.metaKey && !r.ctrlKey), suggesting the intent was to let modified Escape through — but this guard is missing on at least one handler that owns focus when the user is typing in the input.

Suggested fix

Either:

  • (a) Add the !metaKey && !ctrlKey guard to the remaining Escape handlers in the webview, so cmd+escape propagates to VS Code and the existing keybinding does the blur; or
  • (b) When the webview's input itself sees cmd+escape, explicitly post a message to the host to invoke claude-vscode.blur (and stop propagation locally so other handlers don't see it).

Option (a) is the smaller change and keeps the contract that VS Code keybindings own modified-Escape behavior.

Workaround (for users hitting this)

Bind a non-Escape combo that the webview doesn't intercept, chained via runCommands, in keybindings.json:

{
    "key": "ctrl+8",
    "command": "runCommands",
    "args": {
        "commands": [
            "claude-vscode.blur",
            "workbench.action.focusActiveEditorGroup"
        ]
    }
}

This bubbles up cleanly because the webview's handlers don't intercept Ctrl+digit keys.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗