gpt4 book ai didi

Disable ctrl-b keyboard shortcut in Firefox?(是否禁用Firefox中的ctrl-b键盘快捷键?)

转载 作者:bug小助手 更新时间:2023-10-25 11:50:34 36 4
gpt4 key购买 nike



As a tmux user, there is a lot of Ctrl+b going on. Also a lot of Firefox.

作为tmux用户,有很多Ctrl+b正在进行。还有很多火狐。



It's safe to say I never, ever want to see the book mark vertical bar. No interest. Never had any in 20 years of computer use.

可以肯定地说,我从来没有,从来没有想过看到书签竖线。不感兴趣。在使用电脑的20年里,我从来没有使用过任何电脑。



Is there any way to disable Ctrl+b in Firefox without using a plug-in?

有没有办法在不使用插件的情况下禁用Firefox中的Ctrl+b?


更多回答
优秀答案推荐

I've been able to disable the Ctrl+B shortcut by using the Shortkeys extension.

我已经能够使用快捷键扩展来禁用Ctrl+B快捷键。


Its configuration can be a little cumbersome, so here's a quick guide:

它的配置可能有点麻烦,所以这里有一个快速指南:



  • In the extensions page (about:addons), click the ... menu next to the Shortkeys entry, and select "Preferences"

  • Add a new shortcut:

    • In the "Shortcut" column, type "Ctrl+B".

    • In the "Label" column, enter something like "Disable bookmarks sidebar".

    • In the "Behavior" column, select the "Do nothing" entry



  • Don’t foget to click the Save shortcuts button at the bottom of the page!


Note: This only works in the context of a web page. The default Firefox action will still execute if you press Ctrl+B while the cursor is e.g. in the URL bar or the search bar. But for me it's a great improvement already!

注意:这只适用于网页环境。如果您在光标位于URL栏或搜索栏中时按Ctrl+B,则仍会执行默认的Firefox操作。但对我来说,这已经是一个巨大的进步了!



Since Firefox 72, this needs to be done with autoconfig.js. See Firefox documentation and example usage.

从Firefox72开始,这需要使用aufig.js来完成。请参阅Firefox文档和用法示例。


OLD WAY: This can be accomplished using userChrome.js

老方法:这可以使用userChrome.js来完成


Use the following code:

使用以下代码:


var key = document.getElementById('viewBookmarksSidebarKb');
if (key) key.remove();

Credit - I found this thanks to this answer https://superuser.com/questions/1318336/how-to-disable-ctrlq-shortcut-in-firefox-on-linux/1348082#1348082

信用-多亏了这个答案https://superuser.com/questions/1318336/how-to-disable-ctrlq-shortcut-in-firefox-on-linux/1348082#1348082我找到了这一点



I realise in the original question is the qualifier "without a plugin", however my answer is helpful to those without that restriction. I've found a way to do this using a Greasemonkey script in Firefox for macOS.

我意识到在原来的问题中是限定词“没有插件”,然而我的答案对那些没有这个限制的人是有帮助的。我已经找到了一种方法,可以使用MacOS版Firefox中的Gresemonkey脚本来实现这一点。


Firstly, install the Greasemonkey Extension for Firefox and give it the appropriate permissions (e.g. “Run in Private Windows” if desired). Then add the following “New user script…”:

首先,安装Firefox的Gresemonkey扩展,并给它适当的权限(例如“在私有Windows中运行”(如果需要)。然后添加以下“新用户脚本…”:


// ==UserScript==
// @name Disable “Bookmarks Sidebar” keyboard shortcut
// @description Disables the Ctrl+B and Cmd+B keyboard shortcuts in Firefox
// @version 1
// @grant none
// ==/UserScript==

window.addEventListener('keydown', function(event) {
if (event.metaKey && event.keyCode == 66) { //macOS: Checks if Cmd and B are pressed
event.preventDefault(); //Blocks default event handler
}
if (event.ctrlKey && event.keyCode == 66) { //Windows: Checks if Ctrl and B are pressed
event.preventDefault(); //Blocks default event handler
}
}, false);

In the above code, the keyboard key "B" corresponds with the number 66, but you could of course change this for other keyboard shortcuts too.

在上面的代码中,键盘键“B”对应于数字66,但您当然也可以将其更改为其他键盘快捷键。


Unfortunately, this doesn't work if the URL address bar, or the search box, are selected. But it does work after webpages have loaded, or if any elements are clicked on within the webpage. So this is a workaround / partial solution.

遗憾的是,如果选择了URL地址栏或搜索框,则此操作不起作用。但在网页加载后,或者如果网页中的任何元素被点击,它确实会起作用。因此,这是一种变通方法/部分解决方案。



Many topics on this and none seem to work, so I've just hand-rolled something that does seem to work. This is JavaScript-only, with no try/catch blocks for clarity.

关于这方面的很多话题似乎都不管用,所以我只是手摇了一些看起来管用的东西。这是纯JavaScript的,为了清楚起见,没有使用try/Catch块。


Goal: In contentEditable DIV, prevent Firefox from processing Ctrl-B, so we can use it to set the text content to BOLD.

目标:在内容可编辑的DIV中,阻止Firefox处理Ctrl-B,这样我们就可以使用它将文本内容设置为粗体。


Basic idea is to stop propagation at the body (suppress bubble up to browser), while setting bold at the control (allowing bubble-down to text that is being edited in the div). Solution is FF-only, since that is the question, but I can extend it to Webkit and IE on request.

基本思想是在正文停止传播(将气泡向上抑制到浏览器),同时在控件设置粗体(允许向下气泡到div中正在编辑的文本)。解决方案是仅FF-Only,因为这是一个问题,但我可以根据要求将其扩展到Webkit和IE。


HTML:

Html:



<body onkeydown="bodyKeyHandler(this, event);">
<div contentEditable="true" onkeydown="editorKeyHandler(event);"></div>
</body>

JAVASCRIPT:

JavaScrip:



function bodyKeyHandler(o,e) {
var c = e.ctrlKey;
var k = e.which;
if (e.ctrlKey) {
switch ( k ) {
case 17:
e.preventDefault();
o.stopPropagation();
break;
}
}
}

function editorKeyHandler(e) {
var c = e.ctrlKey;
var k = e.which;
if (c) {
switch ( k ) {
case 17:
document.execCommand("bold");
break;
}
}
}

One important warning, when fiddling with this in FF, injecting alert() to see what's happening will break it, because the alert popup will capture and bubble the event to the browser! To see it working, remove all tracing.

一个重要的警告是,当在FF中处理这一点时,注入ert()来查看发生了什么将破坏它,因为警报弹出窗口将捕获事件并将其冒泡到浏览器!要查看它的工作情况,请删除所有跟踪。


更多回答

This doesn't seem to work for macOS. I have tried all three options: "Ctrl+B", "Cmd+B", "Command+B"

这似乎不适用于MacOS。我尝试了所有三个选项:“Ctrl+B”、“Cmd+B”、“Command+B”

Unfortunately, since Firefox 72 (January 2020) this option doesn't work anymore :(

不幸的是,自Firefox72(2020年1月)起,此选项不再起作用:(

@waldyrious Thanks for adding the comment. It still works using a slightly different way so I updated my answer.

@waldyrious感谢您添加评论。它仍然以一种略有不同的方式工作,所以我更新了我的答案。

This only works when in a web page that has code like this to bind the Ctrl+B shortcut using JavaScript. This is the case, for instance, in StackOverflow and GitHub text boxes (try focusing the answer box below and pressing Ctrl+B to see it in action). However, the original question is about disabling the Ctrl+B shortcut across the browser, regardless of the page one's in and what element is currently focused. This solution, unfortunately does not do that.

这只在网页中使用JavaScript绑定Ctrl+B快捷键的代码中才有效。例如,在StackOverflow和GitHub文本框中就是这种情况(尝试聚焦下面的答案框并按Ctrl+B查看实际情况)。然而,最初的问题是关于在浏览器中禁用Ctrl+B快捷键,而不考虑它所在的页面和当前聚焦的元素。不幸的是,这个解决方案并没有做到这一点。

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com