Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/agent/src/screen-keys.js
iris ff7215a4b1 agent: let the screen page keep reload, the address bar and its own buttons
The page forwarded every key to the remote desktop and cancelled it, so F5 and
Ctrl+R could not reload, though the disconnect message tells the operator to
reload, and Enter or Space on the fit and debug buttons did nothing. F5, F12,
Ctrl/Cmd+R, Ctrl/Cmd+L and any key pressed on a button now go to the browser;
the rest still go to the remote desktop. The filter is a small module with a
test, bundled for the page as static/screen-keys.js, and the agent-page doc
describes it.
2026-11-25 19:50:22 +01:00

17 lines
817 B
JavaScript

// Which key events the screen page leaves to the browser instead of sending to
// the remote desktop. Kept apart from `screen.html` so a test can load it;
// `build.mjs` bundles it as `static/screen-keys.js`, which the page loads ahead
// of its own script as `hiveScreenKeys`.
/**
* Keys that belong to the browser or to the page's own buttons: reload (F5,
* Ctrl/Cmd+R), the address bar (Ctrl/Cmd+L), the dev tools (F12), and any key
* pressed while a button has focus (so Enter and Space can click it).
*
* @param {{ key: string, ctrlKey?: boolean, metaKey?: boolean, target?: any }} ev
*/
export function keepForBrowser(ev) {
if (ev.target?.closest?.("button")) return true;
if (ev.key === "F5" || ev.key === "F12") return true;
return Boolean(ev.ctrlKey || ev.metaKey) && /^[rl]$/i.test(ev.key);
}