在Mozilla全屏显示时访问转义键 [英] accessing escape key when mozilla is in full screen

查看:45
本文介绍了在Mozilla全屏显示时访问转义键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当Firefox处于全屏模式时,无法覆盖Firefox的转义键功能.正常吗这是我的取消按钮全屏显示的代码:

Not able to override firefox's escape key functionality when firefox is in full screen mode. Is it normal? Here is my code to cancel fullscreen on button click:

功能cancelFullscreen(){if(document.cancelFullScreen){document.cancelFullScreen();} else if(document.mozCancelFullScreen){document.mozCancelFullScreen();} else if(document.webkitCancelFullScreen){document.webkitCancelFullScreen();}}

在所有浏览器上都可以正常工作,希望使用mozilla,似乎无法覆盖或对转义键进行键入.

Works fine on all browsers expect mozilla, can't seem to override or do a keyup for escape key.

推荐答案

在设置全屏视频播放器时遇到了类似的问题.Firefox似乎保留了转义键,并且不允许您使用keydown,keyup或keypress覆盖或更改其功能.

I ran into a similar problem while setting up a full screen video player. It appears that Firefox reserves the escape key and will not let you override or change its functionality using keydown, keyup, or keypress.

但是,当屏幕从全屏切换到非全屏时,您可以添加事件侦听器并添加功能,如下所示:

However you can add an event listener and add functions when the screen toggles from full screen to non-full screen like so:

function isFullScreen() {
    // do stuff for full screen
}

function notFullScreen() {
    // do stuff for non-full screen
}

document.addEventListener("mozfullscreenchange", function () {
    (document.mozFullScreen) ? isFullScreen() : notFullScreen();
}, false);

或者没有像这样的三元运算符:

Or without the ternary operator like so:

document.addEventListener("mozfullscreenchange", function () {
    if (document.mozFullScreen) {
        isFullScreen();
    } else {
        notFullScreen();
    }
}, false);

这篇关于在Mozilla全屏显示时访问转义键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆