How to prevent the "Escape" key from exiting fullscreen mode? #3985
Unanswered
jaredkrinke
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
It looks like if I programmatically (via JavaScript) enter fullscreen mode (
document.documentElement.requestFullscreen()
), then if the user presses the "Escape" key, the fullscreen element is marked as no longer being fullscreen.This happens even if AreBrowserAcceleratorKeysEnabled is false and I add an AcceleratorKeyPressed handler and set Handled=TRUE for VK_ESCAPE. This is surprising because "'Escape' to exit fullscreen" really seems like a browser hotkey/accelerator, and not normal Win32 behavior.
Is there any way to disable this behavior?
Context
My app manages fullscreen via JavaScript (implemented on the C++ side using ContainsFullScreenElementChanged) and the "Escape" key is used (again, via JavaScript) for other purposes (popping up an in-app menu), so I don't want WebView2 to be exiting fullscreen of its own volition (even though this is the normal behavior in the browser).
This is especially inconvenient since there appears to be no way to distinguish "element is no longer fullscreen because WebView2 observed an "Escape" key press" vs. "element is no longer fullscreen because JavaScript code called
document.exitFullscreen()
".Potential work-around
As a work-around, I'm going to stop using ContainsFullScreenElementChanged/AcceleratorKeyPressed, and just expose a host object with a function for toggling fullscreen (and the understanding of fullscreen will be entirely within my C++ code). That way WebView2 calling ContainsFullScreenElementChanged has no effect.
Beta Was this translation helpful? Give feedback.
All reactions