Disable ctrl-b keyboard shortcut in Firefox?

datakid

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?

John Scott Winship

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Disable UITextField keyboard shortcut suggestions

From Dev

How to disable Ctrl + Shift + C shortcut in Firefox?

From Dev

How to disable the keyboard shortcut to switch between workspaces?

From Dev

Is it possible to disable and enable my trackpad with a keyboard shortcut?

From Dev

Firefox: keyboard shortcut for 'Highlight all' in find bar

From Dev

How do I disable a keyboard shortcut?

From Dev

Is it possible to disable and enable my trackpad with a keyboard shortcut?

From Dev

Disable `ctrl+shift+w` shortcut in Firefox Linux

From Dev

Disable Alt + Arrow display flip keyboard shortcut

From Dev

Firefox: change/disable default keyboard shortcut configuration

From Dev

Firefox keyboard shortcut to save current page to Pocket

From Dev

How to disable Unity keyboard shortcut for Spread mode

From Dev

Disable keyboard shortcut Ctrl+Alt+F11 (Gnome?)

From Dev

How to forbid keyboard shortcut stealing by websites in Firefox

From Dev

Enable/Disable a network adapter with a keyboard shortcut

From Dev

Is there a keyboard shortcut to enter Reader View in Firefox?

From Dev

How to disable “Ctrl+Shift+J” shortcut on a MacBook Pro’s Japanese keyboard?

From Dev

Keyboard shortcut for "parent directory" in Firefox or Chrome?

From Dev

What is the keyboard shortcut opposite to Ctrl+k?

From Dev

Keyboard shortcut to close the Firefox Web Console?

From Dev

How to disable the keyboard shortcut to switch between workspaces?

From Dev

Is there a keyboard shortcut for "save link as" in firefox or chrome?

From Dev

How to disable Ctrl+Q shortcut in Firefox on Linux

From Dev

Disable Windows logo key + Ctrl + S keyboard shortcut

From Dev

How to open the Firefox History window with a keyboard shortcut?

From Dev

Disable Alt+` keyboard Shortcut in Linux

From Dev

Keyboard shortcut to toggle (enable/disable) laptop touchpad

From Dev

Delay when using ctrl + s keyboard shortcut

From Dev

disable non listed keyboard shortcut

Related Related

  1. 1

    Disable UITextField keyboard shortcut suggestions

  2. 2

    How to disable Ctrl + Shift + C shortcut in Firefox?

  3. 3

    How to disable the keyboard shortcut to switch between workspaces?

  4. 4

    Is it possible to disable and enable my trackpad with a keyboard shortcut?

  5. 5

    Firefox: keyboard shortcut for 'Highlight all' in find bar

  6. 6

    How do I disable a keyboard shortcut?

  7. 7

    Is it possible to disable and enable my trackpad with a keyboard shortcut?

  8. 8

    Disable `ctrl+shift+w` shortcut in Firefox Linux

  9. 9

    Disable Alt + Arrow display flip keyboard shortcut

  10. 10

    Firefox: change/disable default keyboard shortcut configuration

  11. 11

    Firefox keyboard shortcut to save current page to Pocket

  12. 12

    How to disable Unity keyboard shortcut for Spread mode

  13. 13

    Disable keyboard shortcut Ctrl+Alt+F11 (Gnome?)

  14. 14

    How to forbid keyboard shortcut stealing by websites in Firefox

  15. 15

    Enable/Disable a network adapter with a keyboard shortcut

  16. 16

    Is there a keyboard shortcut to enter Reader View in Firefox?

  17. 17

    How to disable “Ctrl+Shift+J” shortcut on a MacBook Pro’s Japanese keyboard?

  18. 18

    Keyboard shortcut for "parent directory" in Firefox or Chrome?

  19. 19

    What is the keyboard shortcut opposite to Ctrl+k?

  20. 20

    Keyboard shortcut to close the Firefox Web Console?

  21. 21

    How to disable the keyboard shortcut to switch between workspaces?

  22. 22

    Is there a keyboard shortcut for "save link as" in firefox or chrome?

  23. 23

    How to disable Ctrl+Q shortcut in Firefox on Linux

  24. 24

    Disable Windows logo key + Ctrl + S keyboard shortcut

  25. 25

    How to open the Firefox History window with a keyboard shortcut?

  26. 26

    Disable Alt+` keyboard Shortcut in Linux

  27. 27

    Keyboard shortcut to toggle (enable/disable) laptop touchpad

  28. 28

    Delay when using ctrl + s keyboard shortcut

  29. 29

    disable non listed keyboard shortcut

HotTag

Archive