Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#2084·noVNC

Feature request: a public way to choose the keyboard target element

Author: viiqswimCreated Sep 28, 2026Updated Sep 28, 2026

Use case

We embed the noVNC canvas in a page where people type into a remote browser window (a sign-in flow: the person sees a live view of a browser and types a password into it). Some of our users have keyboard-shortcut extensions installed, Vimium being the common one. Vimium intercepts key presses on a page unless focus is sitting on an editable element (an input or textarea); it leaves those alone. The noVNC canvas is not an editable element, so a user with Vimium on can click into the canvas, start typing, and have the extension grab their keystrokes instead of the remote session.

Our workaround is a hidden textarea that we focus in place of the canvas, so extensions like Vimium treat it as text entry and stand down, and we forward its key events into the connection ourselves. That works, but only because we're reaching into a private field to do it.

What's private today

RFB always listens for keyboard input on its own canvas. There's no public way to point it anywhere else:

  • The Keyboard instance is created against this._canvas in the constructor: core/rfb.js:269
  • It's grabbed again once the server handshake finishes: core/rfb.js:2211 (if (!this._viewOnly) { this._keyboard.grab(); })
  • The viewOnly setter grabs/ungrabs the same way: core/rfb.js:317-319

_keyboard and its target are both private, so the only way to change where keys are read from today is reaching into rfb._keyboard._target, which obviously isn't something we'd want to rely on long-term.

Request

A small, backward-compatible way to choose the keyboard target element, for example a keyboardTarget constructor option that defaults to the canvas (so existing behavior is unchanged), or a setter alongside viewOnly. That would let an embedding page hand RFB whatever element it controls, so extensions that special-case editable elements simply leave it alone.

Happy to try drafting a PR for this if a keyboardTarget option (or similar) sounds like a reasonable shape. Checked against version 1.7.0.

Source: novnc/noVNC

View original on GitHubView discussion on GitHub