Ledivin
Ledivin

Reputation: 637

Disable Browser Shortcut Keys

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

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).

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
    }
}

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.

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.

Upvotes: 5

Views: 8176

Answers (1)

Mike Brant
Mike Brant

Reputation: 71422

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

Upvotes: 3

Related Questions