首页 > 解决方案 > 在没有插件的情况下重新绑定 Firefox 中的下一个/上一个选项卡

问题描述

我在 Linux 上使用了一个名为 Autokey 的工具,这样我就可以将下一个/上一个选项卡绑定到我想要在所有应用程序中使用的热键。在大多数情况下,当我需要使用 mac 时,内置的 OSX 键映射器可以完成这项工作。问题是它只能触发在应用程序中显示为菜单项的操作,而 Firefox 实际上并没有像 Chrome 那样的“下一个选项卡”或“上一个选项卡”菜单项。

我宁愿不安装 Firefox 插件只是为了绑定某些功能。他们最终总是让我在其他操作系统上变得混乱或变得过时。是否可以创建一个为 Firefox 提供菜单项的扩展,这样我就可以在 OSX 中使用内置的键盘快捷键实用程序?还有其他方法可以获得我想要的键绑定吗?

标签: firefoxfirefox-addon

解决方案


我最终以更类似于 Autokey 的工作方式的方式使用 Karabiner 解决了这个问题。这是将我首选的下一个/上一个键绑定映射到 Firefox(和 iTerm)所需的 json 配置。

{
    "global": {
        "check_for_updates_on_startup": true,
        "show_in_menu_bar": true,
        "show_profile_name_in_menu_bar": false
    },
    "profiles": [
        {
            "complex_modifications": {
                "parameters": {
                    "basic.simultaneous_threshold_milliseconds": 50,
                    "basic.to_delayed_action_delay_milliseconds": 500,
                    "basic.to_if_alone_timeout_milliseconds": 250,
                    "basic.to_if_held_down_threshold_milliseconds": 500,
                    "mouse_motion_to_scroll.speed": 100
                },
                "rules": [
                    {
                        "manipulators": [
                            {
                                "type": "basic",
                                "description": "next tab in firefox",
                                "from": {
                                    "key_code": "l",
                                    "modifiers": {
                                        "mandatory": ["left_control", "left_gui"]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "tab",
                                        "modifiers": ["left_control"]
                                    }
                                ],
                                "conditions": [
                                    {
                                        "type": "frontmost_application_if",
                                        "bundle_identifiers": [
                                            "org.mozilla.firefox",
                                            "com.googlecode.iterm2"
                                        ]
                                    }
                                ]

                            },
                            {
                                "type": "basic",
                                "description": "prev tab in firefox",
                                "from": {
                                    "key_code": "h",
                                    "modifiers": {
                                        "mandatory": ["left_control", "left_gui"]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "tab",
                                        "modifiers": ["left_control", "left_shift"]
                                    }
                                ],
                                "conditions": [
                                    {
                                        "type": "frontmost_application_if",
                                        "bundle_identifiers": [
                                            "org.mozilla.firefox",
                                            "com.googlecode.iterm2"
                                        ]
                                    }
                                ]

                            }
                        ]
                    }
                ]
            }
        }
    ]
}

我使用 Ergodox 键盘,我的编程方式使我的左 alt 键显示为 left_gui。


推荐阅读