The two documents you linked describe:
They are:
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.