Skip to content

Fix keyboard events not reaching web content in BrowserView#303799

Open
u9g wants to merge 2 commits intomicrosoft:mainfrom
u9g:fix/browserview-keyboard-passthrough
Open

Fix keyboard events not reaching web content in BrowserView#303799
u9g wants to merge 2 commits intomicrosoft:mainfrom
u9g:fix/browserview-keyboard-passthrough

Conversation

@u9g
Copy link

@u9g u9g commented Mar 22, 2026

tryHandleCommand in BrowserView's before-input-event handler intercepts keyboard events too aggressively, preventing them from reaching web content in the built-in browser.

Arrow keys with modifiers (Cmd+Arrow, Option+Arrow, Option+Shift+Arrow, etc.) are routed to VS Code's command system instead of passing through for standard text navigation. On macOS this means Cmd+Left/Right (line start/end), Option+Left/Right (word navigation), and Option+Shift+Left/Right (word selection) are all broken in web pages loaded in the built-in browser.

Enter is classified as a "non-editing key", causing it to be intercepted rather than delivered to web page input handlers. This breaks typing in text inputs, forms, and editors (e.g. Monaco) within the built-in browser.

Fix

  • Let all arrow key events pass through to web content unconditionally, since they are standard text navigation keys
  • Remove Enter from the isNonEditingKey list so it reaches web content

u9g added 2 commits March 21, 2026 20:35
The before-input-event handler in tryHandleCommand was intercepting all
arrow key + modifier combinations (Cmd+Arrow, Option+Arrow, etc.) and
routing them to vscode's command system instead of letting them pass
through to web content. This broke standard text navigation in the
built-in browser: Cmd+Arrow for line start/end, Option+Arrow for word
navigation, Option+Shift+Arrow for word selection, etc.

Let all arrow key events pass through to web content unconditionally.
Enter was classified as a "non-editing key" in tryHandleCommand, causing
it to be intercepted and routed to vscode's command system instead of
being delivered to web page input handlers. This broke typing in text
inputs, forms, and editors (e.g. Monaco) within the built-in browser.

Remove Enter from the non-editing key list so it passes through to web
content.
@vs-code-engineering
Copy link
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@kycutler

Matched files:

  • src/vs/platform/browserView/electron-main/browserView.ts

@jruales

Matched files:

  • src/vs/platform/browserView/electron-main/browserView.ts

@vs-code-engineering vs-code-engineering bot added this to the 1.113.0 milestone Mar 22, 2026
@andy9trider69-bit
Copy link

andy9trider69-bit commented Mar 22, 2026 via email

@andy9trider69-bit
Copy link

andy9trider69-bit commented Mar 22, 2026 via email

u9g added a commit to u9g/LearnTensors that referenced this pull request Mar 22, 2026
vscode's BrowserView intercepts Enter and Option+Arrow keydown events
before they reach web content. Work around this by explicitly binding
Enter via addCommand and intercepting corrupted Option+Arrow keydowns
on the textarea to fire word-navigation commands on keyup.

See microsoft/vscode#303799
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants