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 | 4 Comments

4 Responses to “Disable F12 from opening the Developer Console in Chrome”

  1. Ian Kelling says:

    I installed your extension and F12 still opens the console every time. Any help you can offer? Chrome 18.0.1025.151 m.

  2. Ian Kelling says:

    Actually, I enabled the option to work in incognito mode and now it works fine.

  3. Ian Kelling says:

    Even though I was not in inconito mode.

  4. YOUNGSTER says:

    i have an easy idea.
    step1:- simply download & add firebug lite from chrome web store.

    step2:- by clicking on firebug lite, enable firebug.

    step3:- now press the button F12.

    now you see that chrome console has not opening but the firebug lite has open.

    to throw this problem.

    step4:- simply click again on firebug lite.

    now when you want firebug open. firebug is very trustable.

Leave a Reply