-
-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect when exiting fullscreen is triggered by ESC key press #179
Comments
I don't think browsers expose this information at all.
This could possibly be added. |
perhaps you can test for the ESC key (window.addEventListener( "onkeyup", ... ) there is also https://stackoverflow.com/questions/10706070/how-to-detect-when-a-page-exits-fullscreen |
any workarounds ? |
// you can use it like this, // And don't forget to import useCallback from react, hope this helps ;) |
const isFullscreen = !!document.fullscreenElement; You could use this inside your change handler. |
You could check for ESC key within your change handlerclass FullScreenExitHandler {
static ESCKeyPressed = false;
onFullScreenChange = () => {
/** Full Screen Change Logic */
if (FullScreenExitHandler.ESCKeyPressed) {
/** ESC Key Pressed was used to exit fullscreen */
}
/** Setting ESC key staus to default */
FullScreenExitHandler.ESCKeyPressed = false;
};
}
/** Checks for keypresses on the dom */
window.addEventListener("keydown", function (event) {
if (event.keyCode === 27) {
FullScreenExitHandler.ESCKeyPressed = true;
}
}); |
if (document.addEventListener) { const exitHandler = () => { |
Hello,
When binding a function to "change" event, through
.on()
method, how is it possible to detect either :I couldn't find such information in the
event
object.What I'm trying to achieve is to detect when the browser is exiting fullscreen mode because ESC key was pressed.
Thanks for any help, screenfull is great,
Mathias
The text was updated successfully, but these errors were encountered: