79249309

Date: 2024-12-03 22:11:52
Score: 0.5
Natty:
Report link

The two documents you linked describe:

  1. compiling your own build or
  2. changing a configuration option.

They are:

  1. insanely more than you need to solve the problem and
  2. non-existent for Ctrl-K

Although Firefox captures Ctrl-K (aka cmd-K in Mac OS) as a shortcut, it can be intercepted by JavaScript. Your question implies that some web pages that you use already capture it. However, they appear not to be preventing the default action (search).

An extension that prevents the browser default should work for you. (I cannot test it on a Mac.) If the focus is somewhere outside the document, Ctrl-K would still focus/popup the search bar, but then it wouldn't have been sent to the web page, anyway, for whatever purpose the web page wanted it.

manifest.json

{
  "manifest_version": 2,
  "name": "Answer",
  "description": "Answer a Stack Overflow question",
  "version": "0.1",
  "content_security_policy": "default-src 'none'; object-src 'none'",
  "browser_specific_settings": {
    "gecko": {
      "id": "[email protected]"
    }
  },
  "content_scripts": [ {
    "js": [ "content.js" ],
    "matches": [ "*://*/*" ]
  } ]
}

content.js

( function () {
  'use strict';

  function onKeydown( e ) {
    if ( !e.altKey && e.ctrlKey && !e.shiftKey && e.key === 'k' ) {
      e.preventDefault();
    }
  }
  document.addEventListener( 'keydown', onKeydown );
} () );

As an aside, there are some shortcuts that cannot be overridden by JavaScript. Ctrl-N comes to mind.

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Blacklisted phrase (0.5): I cannot
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Nanigashi