Is it possible to disable the ⌘-[0-9] keyboard shortcuts in Chrome's developer tools? It's frustrating to accidentally hit them when I intend to switch tabs (ex, when I hit ⌘-1 because I want to switch to the first tab, but instead being taken to the developer tools "Elements" panel).
-
At least in Linux, I can use Alt+
to switch tabs. In OS X, that'd be Option+ – Rob W Apr 10 '13 at 11:06. Does it work? -
No… It's ⌘+
on the mac, and option+ – David Wolever Apr 10 '13 at 19:29does nothing. -
1This is a known issue and should be fixed shortly. https://code.google.com/p/chromium/issues/detail?id=174606 – Tim S. Apr 10 '13 at 20:16
1 Answers
Update: This feature has landed in Chrome 28.
- Open the devtools.
- Click on the Gears icon in the bottom-right corner
- Select the General tab
- Use the checkbox before "Enable Ctrl + 1-9 shortcut to switch panels" to toggle the preference. This option is found in the bottom-right corner of the Settings -> General tab.
Previous answer, which shows how to easily change the source code of your devtools.
There's no preference or flag to change the shortcuts, so you either have to edit the source code and build Chrome yourself, or change one byte in resources.pak
.
First, locate
resources.pak
. This archive (format described here) contains several static files.resources.pak
is located in the following directory:- OS X 10.7.3:
/Applications/Google Chrome.app/Contents/Versions/26.0.1410.65/Google Chrome Framework.framework/Resources/resources.pak
- Linux (ArchLinux):
/usr/lib/chromium/resources.pak
- Windows XP:
%AppData%\..\Local Settings\Application Data\Google\Chrome\26.0.1410.65\resources.pak
- Windows Vista/7/8:
%LocalAppData%\Google\Chrome\26.0.1410.65\resources.pak
If you cannot find the file at the specified path, use your common sense. Adjust the version, Chrome/Chromium for example. Locate the Chrome executable, and find
resources.pak
close to it.- OS X 10.7.3:
Create a back-up of resources.pak in case you mess up.
- Open
resources.pak
(usevim
or any other hex editor). - Find
_keyDown:
, and move a few lines forward (see below). Change!
to~
. What does this do? For all given inputs,~value
will return a negative number, which is truthy, so the_keyDown:
function always ends early.
I've confirmed that the Ctrldigit shortcut is disabled in Chrome/Chromium on Linux/Mac/Windows by following these steps.
What could go wrong?
- You trashed some bytes, e.g. by using Notepad to save
resources.pak
. - You did not edit one byte, but added/removed a byte. Remember, the resource's size is fixed!
In any of these cases, the developer tools will show up as "Not found". Chrome itself is still usable though: Sites can be browsed. If you forgot to make a backup at step 3, re-installing Chrome will fix any issues.
For future reference, part of the source code (source with comments at InspectorView.js
):
(in the boldfaced line, replace !
with ~
)
_keyDown: function(event) { if (!WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)) return; if (!event.shiftKey && !event.altKey && event.keyCode > 0x30 && event.keyCode < 0x3A) { var panelName = this._panelOrder[event.keyCode - 0x31]; if (panelName) { this.showPanel(panelName); event.consume(true); } return; }

- 341,306
- 83
- 791
- 678