当前位置: 首页 > news >正文

[Firefox/快捷键] 禁用Ctrl-W快捷键

最近给Firefox这一快捷键坑了几次。恰好发现在CMU也有人遇到类似的烦恼,找到一篇基于Linux的教程。
我使用的是Windows,所以根据自己的情况做了些修改,成功了。小众需求就犯懒直接将笔记贴上了,如果有谁用得上的话,我写个中文版。

Disabling the Ctrl-W shortcut on Firefox

Many vim users use ctrl-w to delete a word. Unfortunately on Firefox, this closes the current tab. So if you’re editing a text area / filling out a form you may accidentally close the tab.

There’s no option to change or disable default keyboard shortcuts (Firefox 98, 2022-03-29 // Firefox 117依然不支持). So if you want to do it, you need to edit files manually.

To disable ctrl-w shortcut in Firefox, you need to manually edit the file:

  • /usr/lib/firefox/browser/omni.ja (Linux) .
  • "/c/Program Files/Mozilla Firefox/browser/omni.ja" (Windows)

Modify the File

Run git bash in administration mode.

First unzip it to a temporary directory:

mkdir /tmp/firefox-omni
cd /tmp/firefox-omni
unzip "/c/Program Files/Mozilla Firefox/browser/omni.ja"

Now you need to edit ./chrome/browser/content/browser/browser.xhtml to make your changes. You can change as many shortcuts as you want here. The ctrl-w key is called close-shortcut. You can either

  • comment out the offending line, or
  • change modifiers="accel,shift" to require ctrl-shift-w to close tabs.

Note, the above instructions only make Ctrl-W an unreserved shortcut. This means extensions can now remap it. If you don’t have any extensions that remap it then Ctrl-W will still close your current window.

If you’d like to simply disable Ctrl-W, then just comment out the above shortcut definitions entirely (instead of only changing reserved="true" to reserved="false" as I suggest above).

Here is how to comment it out:

<key id="key_close" data-l10n-id="close-shortcut" command="cmd_close" modifiers="accel" reserved="true"/>

Now switch to root, and install your changes:

cd /tmp/firefox-omni
zip -0DXqr /tmp/omni.ja * # I have install `zip` into DELL
cd "/c/Program Files/Mozilla Firefox/browser"cp ./omni.ja ./omni.ja.bkup # backupcp /tmp/omni.ja ./omni.ja # TOCHECK: if the first path is correct
rm -r /tmp/omni.ja /tmp/firefox-omni

Clear Firefox Start Cache and Restart

In URI panel, enter about:support

Click “Clear startup cache…” on the right, and click restart. (opened pages won’t be lost)

Done🍺

Note: You will have to do this every time you reinstall firefox. I automated the above into a script. First save firefox-omni.patch as ~/local/src/firefox-omni.patch, and then download and run this script as a normal users (that has sudo privileges).

Reference

https://www.math.cmu.edu/~gautam/sj/blog/20220329-firefox-disable-ctrl-w.html

http://www.lryc.cn/news/172368.html

相关文章:

  • Git常用命令diff和mv
  • 【谢希尔 计算机网络】第3章 数据链路层
  • 《DevOps实践指南》- 读书笔记(九)
  • 数据库数据恢复-SQL SERVER数据库分区被格式化的数据恢复方案
  • ubuntu安装ffmpeg
  • CentOS上安装Docker
  • 三相PWM整流器有限集模型预测电流控制MATLAB仿真模型
  • 【JavaEE】多线程(三)
  • 9.25day5---Qt
  • wpf制作自定义控件,并触发外部路由事件
  • axios全局路由拦截的设置方法
  • XSS跨站脚本攻击
  • Java8实战-总结33
  • Postman 的使用教程(详细)
  • 单元测试 —— JUnit 5 参数化测试
  • uview组件库的安装
  • skywalking入门
  • 【Java 基础篇】Java多线程实现文件上传详解
  • 【计算机基础】VS断点调试,边学边思考
  • BD就业复习第五天
  • ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the ‘ssl‘
  • Qt5开发及实例V2.0-第十二章-Qt多线程
  • Windows 修改系统默认字体
  • 图像处理软件Photoshop 2024 mac新增功能
  • JavaScript之观察者模式
  • 深入了解ln命令:创建硬链接和符号链接的实用指南
  • 虚拟IP技术
  • 蓝桥杯 题库 简单 每日十题 day5
  • 【计算机网络】图解路由器(一)
  • C语言文件的相关操作