Skip to content

VSCode extension: keyboard shortcuts (/, ctrl+p, ctrl+b, etc.) not working in webview panel #26519

@akak2018

Description

@akak2018

Description

Description

When using the OpenCode VSCode extension (not the terminal/TUI version),
keyboard shortcuts defined by OpenCode do not work because VS Code intercepts
them before they reach the webview panel.

Environment

  • OpenCode version: (your version)
  • VS Code version: (your version)
  • OS: Windows

Shortcuts affected

  • / (slash) — intercepted by VS Code comment action
  • ctrl+p — intercepted by VS Code "Go to File"
  • ctrl+b — intercepted by VS Code sidebar toggle
  • ctrl+j — intercepted by VS Code panel toggle
  • ctrl+r — intercepted by VS Code "Open Recent"
  • ctrl+z — intercepted by VS Code undo

Steps to reproduce

  1. Install the OpenCode VS Code extension
  2. Open the OpenCode panel
  3. Click inside the OpenCode webview to focus it
  4. Try pressing / or ctrl+p
  5. VS Code handles the shortcut instead of OpenCode

Expected behavior

Shortcuts should be captured by the OpenCode webview when it is focused.

Actual behavior

VS Code intercepts the keypresses and triggers its own commands instead.

Notes

This is a known VS Code webview limitation (microsoft/vscode#129178) but it
can be worked around by the extension using webview keyboard event handling.
Other extensions like Cline and Continue have implemented similar workarounds.
The terminalFocus when-condition does not apply here since the extension uses
a webview panel, not a terminal.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions