38

Is there a way to disable and replace shortcut commands in Google Chrome. I want to use Chrome for a public computer that only can access one site. Because of this I want to disable keys like Ctrl+Tab, Ctrl+T, Alt+F4 and I want to change F11 to a command like Ctrl+Shift+Alt+J (example) to stop users from exiting full screen mode.

Settings on the network block everything but a specific domain but now I want to block the user from exiting the browser.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Andreas
  • 6,958
  • 10
  • 38
  • 52

4 Answers4

12

I know this question is quite old, but I found a solution that works for me (and probably many others too). If you don't use the CTRL and ALT keys in the browser at all, you can disable them in the OS itself.

Under Linux, I used xmodmap -pke to find out which key is mapped to which code. Knowing the keycodes, I used:

xmodmap -e "keycode 37 = "
xmodmap -e "keycode 105 = "

to disable both left and right CTRL keys (to prevent something like CTRL+W, CTRL+T, etc.), then with:

xmodmap -e "keycode 133 = "
xmodmap -e "keycode 134 = "

both left and right SUPER keys (Windows Keys) (to prevent opening the start menu and such fancy stuff)

and then finally with xmodmap -e "keycode 105 = " I disabled the ALT key (to prevent ALT+F4, etc.).

And optionally, we can disable F1 too, so that the Chrome Support Page doesn't open, with: xmodmap -e "keycode 67 = "

Finally, let Chromium or Chrome lock the rest down for us using Kiosk Mode:

chromium-browser --kiosk http://example.com/

or

google-chrome --kiosk http://example.com/

And right click is already disabled in kiosk mode, so we don't need to change anything there.

With all that done, the end user can only navigate with the mouse within the predefined webpage (And links leading to some other content, of course) and write stuff with the normal characters on the keyboard, but nothing more. Reloading may be still possible (F5), but even that can be disabled with: xmodmap -e "keycode 71 = "

Caution: Please execute xmodmap -pke first to discover if your keyboard or OS have the same keymapping, or you may disable other normal keys without knowing.

Caution 2: Note that if you've done everyhing above and then launch Chrome or Chromium in Kiosk Mode, you can't get out anymore! Only physically pressing the power button or killing the application over SSH or Telnet will let you resume normal operation again.

To make those changes permanent, read the end of this guide: https://stackoverflow.com/a/11219056/3525780

EDIT: To those who have problems disabling the F1, F5, etc. keys, use following as a workaround:

xmodmap -e "keycode 67 = Escape"

(Somehow those "F keys" need to be assigned to an already existing and assigned key)

Fusseldieb
  • 1,324
  • 2
  • 19
  • 44
  • >> `And optionally, we can disable F1 too, so that the Chrome Support Page doesn't open, with: xmodmap -e "keycode 67 = "` Tried and still have F1 working. Tried also these: `xmodmap -e "keycode 67 = NoSymbol"` `xmodmap -e "keycode 67 = 0x00000"` `xmodmap -e "keycode 67 = F2"` – Drey Jun 30 '17 at 08:12
  • 2
    @Drey I just found out that F1 actually doesn't get affected by xmodmap, it still opens the Help page... I'm searching for a solution for that... – Fusseldieb Jun 30 '17 at 13:04
  • 1
    @Drey Solved. You must set keycode 67 to an *existing* key for whatever reason. I set mine to ESC like so: `xmodmap -e "keycode 67 = Escape"`. Now the help is gone. – Fusseldieb Jun 30 '17 at 13:24
  • Thanks for fast reply, Fusseldieb. I really appreciate it. I already tried to map to End/Home and just now I tried these lines: `xmodmap -e "keycode 67 = Escape"` `xmodmap -e "keycode 69 = F1"`. Both F1 and F3 works as usually (Help and Search respectively). `xmodmap -pke` shows after these lines `keycode 9 = Escape NoSymbol Escape` `keycode 67 = Escape NoSymbol Escape` `keycode 69 = F1 NoSymbol F1` – Drey Jul 02 '17 at 03:46
  • Realized that the whole xmodmap thing stopped working for me =( Previously I successfully disabled Ctrl/Alt/Super modifiers with these lines: `xmodmap -e "clear mod1"`, `xmodmap -e "clear control"`, `xmodmap -e "clear lock"`, `xmodmap -e "clear mod4"`. And now Alt works in chrome again. Checking with `xmodmap -pm` shows all modifiers cleared (except Shift): `xmodmap: up to 2 keys per modifier, (keycodes in parentheses): shift Shift_L (0x32), Shift_R (0x3e) lock control mod1 mod2 mod3 mod4 mod5 `. I'm really frustrated... – Drey Jul 02 '17 at 04:56
  • Managed to block alt modifier like in your answer, but F-keys are still accessible no matter what I do. – Drey Jul 02 '17 at 05:43
  • @Drey Strange... Here it works like a charm now. Seems obvious, but can it be that your keyboard uses a FN Key? Try disabling it (In BIOS, if it's a notebook). – Fusseldieb Jul 03 '17 at 11:22
  • Fusseldieb, using desktop keyboard, no FN-key. Checked keycodes with xev. And as I mentioned before: `xmodmap -pke` shows after these lines `keycode 9 = Escape NoSymbol Escape`, `keycode 67 = Escape NoSymbol Escape`, `keycode 69 = F1 NoSymbol F1`. Binded to existing keys but still no luck( – Drey Jul 05 '17 at 04:54
  • Tried also another form: `keysym F1 = Escape`. `xmodmap -pke` shows `keycode 67 = Escape NoSymbol Escape` but F1 still invokes help page. – Drey Jul 05 '17 at 05:26
  • Telling more details: I don't run X11 on remote server, only Xvnc with startup script (chrome inside it). Seems that is the root cause of F*-keys remap faiulure with xmodmap. Any chances I could block F-keys in my case without installing X11+WM? – Drey Jul 12 '17 at 07:37
  • 1
    Great, thank you very much! Unfortunately, Gnome makes it hard to make changes permanent (https://bugzilla.gnome.org/show_bug.cgi?id=721873). Needed to use the parameter `-display :0` to make it work outside of an X-session. This answer deserves more upvotes. – mm759 Aug 03 '17 at 14:54
  • If you choose this method, the user will not be able to copy and paste? Also, does this work for the virtual button on Windows Tablets? – Pete Jun 11 '18 at 19:59
7

Having recently encountered the same kiosk-type problem (and not being able disable all keys in Chrome) I eventually found a solution which I thought I would share:

Using node-webkit I created the following package.json file:

{
    "name" : "mykiosk",
    "window" : {
        "fullscreen" : true,
        "toolbar" : false
    },
    "main" : "http://the-one-and-only-allowed.url/"
}

Launch with: ./nw

All function keys are blocked. Ctrl+N/T do not create tabs. It is quite nice

One last javascript/onload trick to disable the right-click context menu:

window.oncontextmenu = function(ev) {
  ev.preventDefault();
  ev.stopPropogation();
  return false;
}
Fabrizio
  • 7,603
  • 6
  • 44
  • 104
chriskelly
  • 7,526
  • 3
  • 32
  • 50
  • nice, your solution stops everything on windows but the alt+f4 combo, maybe I can compile a version of nw with a capture event for alt-f4? – Matthew Optional Meehan Mar 18 '15 at 06:39
  • I never tried windows. I don't know any way to prevent alt-f4 from killing the window. If you managed to compile a version of nw that captures alt-f4 I would interested in trying it. – chriskelly Apr 23 '15 at 23:07
4

Chrome has Kiosk Mode, but that won't prevent users from using OS keyboard shortcuts (like ALT+F4, which aren't part of Chrome. Windows handles those). To start it in Kiosk Mode, run it using these parameters:

chrome.exe --kiosk http://www.google.com

My public library actually did something pretty awesome: they installed an extremely minimal Debian build on their kiosks, and run Google Chrome on each one. There are no close buttons, and no desktop to get into, so this deters virtually all the CTRL+ALT+DELETE hackers out there. ALT+F4 doesn't work either, and closing the browser by right-clicking opens up another one instantly.

But they forgot to get rid of GRUB's 10 second timeout, which lets users (well, me) get into recovery mode -_-, so I'm working with them to get that fixed...

I'd seriously consider Linux, as you can install it really quickly on multiple computers and basically forget about viruses and security. But the downside is that there isn't a "Administrator Panel" for you to tweak things with. You'd have to whip out nano (sorry, can't get used to vim) and edit some config files.

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
Blender
  • 289,723
  • 53
  • 439
  • 496
  • Can you tell more about your public library, how did they disable Alt+F4? – Juzer Ali Sep 01 '12 at 10:29
  • Seems that even with Kiosk mode, Chrome still allows shortcuts such as Ctrl-T, Ctrl-N, and Ctrl-W. Thoughts? – Lee Olayvar Aug 12 '13 at 19:10
  • @LeeOlayvar: For that, you can just make a simple full-screen browser with Qt4's QWebkit widget. It only accepts right clicks, which you can disable as well, so the only thing you need to worry about is keyboard input and navigation, but that's not hard to fix. – Blender Aug 12 '13 at 23:21
  • I suppose you're talking about this: [Ubuntu as a Kiosk](http://www.instructables.com/id/Setting-Up-Ubuntu-as-a-Kiosk-Web-Appliance/), right? – Gustavo Carreno Aug 15 '13 at 12:31
1

For me using version 52.0.2743 the --kiosk tag didn't work, but the --app="http://www.example.com" did what I wanted. (Disabled chrome keyboard shortcuts so I could use shellinabox + nano without issue.)

Also works on Chrome Canary (for which the --kiosk tag also didnt' work).

Other possibly helpful links: Chrome support how to make a Kiosk App: https://support.google.com/chrome/a/answer/3316168?hl=en Kiosk App for Chrome: https://chrome.google.com/webstore/detail/kiosk/afhcomalholahplbjhnmahkoekoijban?hl=en

Supaiku
  • 121
  • 5