Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable shortcuts in Google Chrome

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.

like image 509
Andreas Avatar asked Apr 12 '11 15:04

Andreas


People also ask

How do I turn off all shortcuts?

Select “System Preferences.” Select “Keyboard” from the list on the left side of your screen. Click on “Shortcuts” in the list of settings across the top of the window. Once inside “Shortcuts,” uncheck the box next to each shortcut to disable it.


2 Answers

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)

like image 116
Fusseldieb Avatar answered Sep 18 '22 16:09

Fusseldieb


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; } 
like image 40
chriskelly Avatar answered Sep 20 '22 16:09

chriskelly