From da61426fc93cc52631b7344078daf4b479a4f056 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 2 Oct 2025 21:47:30 -0700 Subject: [PATCH] always allow keyboards shortcuts --- nose/ping/index.tsx | 2 +- public/browser-nav.js | 14 ++++++++++++++ src/js/browser.ts | 12 ++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/nose/ping/index.tsx b/nose/ping/index.tsx index bec88b3..3dc3351 100644 --- a/nose/ping/index.tsx +++ b/nose/ping/index.tsx @@ -1,2 +1,2 @@ export default () => - pong pong - {Date.now()} \ No newline at end of file + pongpong - {Date.now()} \ No newline at end of file diff --git a/public/browser-nav.js b/public/browser-nav.js index ee9afc4..5b01da8 100644 --- a/public/browser-nav.js +++ b/public/browser-nav.js @@ -83,6 +83,20 @@ } }) + // Send all keydown events to parent + window.addEventListener('keydown', (e) => { + window.parent.postMessage({ + type: 'KEYDOWN', + data: { + key: e.key, + ctrlKey: e.ctrlKey, + shiftKey: e.shiftKey, + altKey: e.altKey, + metaKey: e.metaKey + } + }, '*') + }) + if (window.parent !== window) { window.parent.postMessage({ type: 'NAV_READY' }, '*') diff --git a/src/js/browser.ts b/src/js/browser.ts index b243e22..2a507d6 100644 --- a/src/js/browser.ts +++ b/src/js/browser.ts @@ -59,6 +59,18 @@ function handleAppMessage(event: MessageEvent) { case 'NAV_BLOCKED': showNavigationError(data.url, data.reason) break + + case 'KEYDOWN': + const keyEvent = new KeyboardEvent('keydown', { + key: data.key, + ctrlKey: data.ctrlKey, + shiftKey: data.shiftKey, + altKey: data.altKey, + metaKey: data.metaKey, + bubbles: true + }) + window.dispatchEvent(keyEvent) + break } }