是否可以在网页全屏模式下以编程方式禁用esc/F11键? [英] Is it possible to disable esc/F11 key during full screen mode of webpage, programmatically?

查看:285
本文介绍了是否可以在网页全屏模式下以编程方式禁用esc/F11键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以以编程方式在网页全屏模式期间禁用esc/F11键?我需要在网页内有一个退出按钮才能退出全屏模式,但需要防止使用其他功能的窗口(例如esc,F11等)退出全屏模式.如果有人对此有任何想法,请帮助我.

Is it possible to disable esc/F11 key during full screen mode of webpage, programmatically? I need to have an exit button within the webpage to exit from fullscreen mode, but need to prevent to come outside the fullscreen mode using other funcationality of windows(like esc, F11, etc.). Please help me if anyone have any idea about this.

推荐答案

使用jQuery,您可以通过侦听keydown事件来禁用它:

With jQuery you can disable it listening to the keydown event:

$(document).on("keydown",function(ev){
	console.log(ev.keyCode);
	if(ev.keyCode===27||ev.keyCode===122) return false
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

键代码27代表ESC键,122代表F11.该产品已在chrome中进行了测试,也许对于其他浏览器可以是其他编号

keycode 27 stands for the ESC key and 122 for the F11. This was tested in chrome, maybe for other browsers can be other number

这篇关于是否可以在网页全屏模式下以编程方式禁用esc/F11键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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