禁用Chrome开发者工具⌘-[0-9]键盘快捷键? [英] Disable Chrome developer tools ⌘-[0-9] keyboard shortcuts?

查看:215
本文介绍了禁用Chrome开发者工具⌘-[0-9]键盘快捷键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Chrome的开发者工具中停用⌘-[0-9] 键盘快捷键?当我打算切换选项卡时(例如,当我点击⌘-1 时意外击中它们是因为我想切换到第一个选项卡,而不是转到开发人员工具元素面板)。

解决方案

更新:此功能登陆Chrome 28 打开

  • 单击右下角的Gears图标

  • 选择常规选项卡

  • 使用启用Ctrl + 1-9快捷方式切换面板前的复选框切换首选项。此选项位于设置 - >常规选项卡的右下角。






  • <以前的答案显示了如何轻松更改开发工具的源代码。



    没有首选项或标记来更改快捷方式,因此您必须自己编辑源代码并构建Chrome, resources.pak 中更改一个字节。


    1. 首先,找到 resources.pak 。此存档(格式描述此处)包含几个静态文件。 resources.pak 位于以下目录中:


      • 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



      如果您无法在指定路径中找到该文件,使用你的常识。例如,调整版本Chrome / Chromium。找到Chrome可执行文件,并在其附近找到 resources.pak

    2. 创建一个备份resources.pak以防万一您搞砸了。 使用 vim 或其他任何十六进制编辑器)。 并向前移动几行(参见下文)。将更改为。这是做什么的?对于所有给定的输入,〜value 将返回一个负数,即truthy,所以 _keyDown:函数总是结束

    我已确认 Ctrl 数字



    有什么可能出错?


    在Linux / Mac / Windows上的Chrome / Chromium中禁用快捷键

    • 您丢弃了一些字节,例如通过使用记事本保存 resources.pak

    • 您没有编辑一个字节,而是添加/删除了一个字节。请记住,资源的大小是固定的!



    在这些情况下,开发人员工具将显示为未找到。尽管Chrome本身仍然可用:可以浏览网站。如果您在第3步忘了备份,重新安装Chrome将解决所有问题。






    部分源代码(来源与 InspectorView.js ):

    (在粗体行中,替换!< code $> $

     
    _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;
    }


    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).

    解决方案

    Update: This feature has landed in Chrome 28.

    1. Open the devtools.
    2. Click on the Gears icon in the bottom-right corner
    3. Select the General tab
    4. 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.

    1. 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.

    2. Create a back-up of resources.pak in case you mess up.

    3. Open resources.pak (use vim or any other hex editor).
    4. 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;
    }
    

    这篇关于禁用Chrome开发者工具⌘-[0-9]键盘快捷键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆