nemrod.se Various guides and experiments

Disable F12 from opening the Developer Console in Chrome


F12 keyLinus Torvalds made a post on Google+ asking if there was a convenient way of disabling F12 from opening the developer console in Chrome (because apparently he’s “totally spastic and uncontrolled” when going for backspace ;)).

I, of course, had to oblige by creating a Chrome extension: Disable F12 on Chrome Web Store

It can access “your data on all websites” because it needs to inject a JavaScript that captures the F12 keypress and prevents the event from going any further. You can inspect the code in the extension yourself but if you can’t be bothered here it is:

manifest.json

{
	"name": "Disable F12",
	"version": "1.0",
	"description": "An extension to disable F12 opening the dev console.",
	"icons": { "128": "icon128.png" },
	"content_scripts": [
		{
			"matches": ["*://*/*"],
			"js": ["disablef12.js"]
		}
	]
}

disablef12.js

window.addEventListener("keydown", keyListener, false);

function keyListener(e) {
	if(e.keyCode == 123) {
		e.returnValue = false;
	}
}

Posted in Chrome Extensions | Leave a comment

Leave a Reply