Linus 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;
}
}
I installed your extension and F12 still opens the console every time. Any help you can offer? Chrome 18.0.1025.151 m.
Actually, I enabled the option to work in incognito mode and now it works fine.
Even though I was not in inconito mode.