禁用浏览器的快捷键 [英] Disable Browser Shortcut Keys

查看:409
本文介绍了禁用浏览器的快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建本质上是一个亭

I am trying to create, essentially, a 'kiosk'

我有希望在屏幕上访问的唯一一个Web应用程序。我知道铬有一个亭模式(快捷键:的chrome.exe --kiosk www.url.com)。这需要照顾的自动全屏的,但禁用很少快捷方式(也许只有F11)。

I have an web application that I want to be the only thing accessible on screen. I know chrome has a 'kiosk' mode (shortcut: chrome.exe --kiosk www.url.com). That takes care of the auto-fullscreen, but disables very few shortcuts (perhaps only f11).

随着一点点从互联网的帮助下,我写了一些JavaScript代码能够完成任务的的的。在code是如下:

With a bit of help from the internet, I wrote out some javascript that gets most of the job done. The code is as follows:

window.onload = function() {
    window.document.body.onkeydown = function() {
        if (event.ctrlKey) {
            event.stopPropagation();
            event.preventDefault();
            try {
                event.keyCode = 0; // this is a hack to capture ctrl+f ctrl+p etc
            }
            catch (event) {

            }
            return false;
        }
        return true; // for keys that weren't shortcuts (e.g. no ctrl) then the event is bubbled
    }
}

这需要照顾之类的东西按Ctrl + F,按Ctrl + P,等等。不幸的是,它的的在按Ctrl + T,CTRL + N,F5等禁用快捷键等。

This takes care of things like ctrl+f, ctrl+p, etc. Unfortunately, it does not disable shortcuts such at ctrl+t, ctrl+n, f5, etc.

它甚至有可能禁用这些,还是我在这里追逐彩虹?我不在乎,如果它的JavaScript,设置什么的,但我真的想这样做的没有的一个插件。

Is it even possible to disable these, or am I chasing a rainbow here? I don't care if it's javascript, settings, whatever, but I would really like to do it without a plugin.

推荐答案

您可以禁用任何你想要的按键通过JavaScript。你只需要知道密钥code他们。

You can disable any keys you want via javascript. You just need to know the key code for them.

这篇关于禁用浏览器的快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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