always allow keyboards shortcuts
This commit is contained in:
parent
ba44f8e65b
commit
da61426fc9
|
|
@ -1,2 +1,2 @@
|
||||||
export default () =>
|
export default () =>
|
||||||
<html><head><title>pong </title></head><body>pong - {Date.now()}</body></html>
|
<html><head><title>pong</title></head><body>pong - {Date.now()}</body></html>
|
||||||
|
|
@ -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) {
|
if (window.parent !== window) {
|
||||||
window.parent.postMessage({ type: 'NAV_READY' }, '*')
|
window.parent.postMessage({ type: 'NAV_READY' }, '*')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,18 @@ function handleAppMessage(event: MessageEvent) {
|
||||||
case 'NAV_BLOCKED':
|
case 'NAV_BLOCKED':
|
||||||
showNavigationError(data.url, data.reason)
|
showNavigationError(data.url, data.reason)
|
||||||
break
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user