As a tmux user, there is a lot of Ctrl+b going on. Also a lot of Firefox.
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.
Is there any way to disable Ctrl+b in Firefox without using a plug-in?
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.
Goal: In contentEditable DIV, prevent Firefox from processing Ctrl-B, so we can use it to set the text content to BOLD.
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.
HTML:
<body onkeydown="bodyKeyHandler(this, event);">
<div contentEditable="true" onkeydown="editorKeyHandler(event);"></div>
</body>
JAVASCRIPT:
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.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments