That shortcut is handled by a keypress handler within the <tabbrowser> before it can reach a <key>.nameanyone wrote:Would like to remap Ctrl-F4 to close a window instead of a tab. How do I disable the Firefox's bulit-in Ctrl-F4 handling?
You could try to build an extension handling that keypress event before the <tabbrowser> by opening your Profile and create within the extensions folder a folder named userxul@nobody containing:
install.rdf
Code: Select all
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/2004/em-rdf#">
<rdf:Description rdf:about="urn:mozilla:install-manifest">
<id>userxul@nobody</id>
<name>User XUL</name>
<version>0</version>
<targetApplication><rdf:Description>
<id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id>
<minVersion>1.0+</minVersion>
<maxVersion>*</maxVersion>
</rdf:Description></targetApplication>
</rdf:Description>
</rdf:RDF>
Code: Select all
content userxul .
overlay chrome://browser/content/browser.xul chrome://userxul/content/browser.xul
Code: Select all
<?xml version="1.0"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"><![CDATA[ window.addEventListener("keypress", function (event){
var modifiers = ["Alt","Control","Meta","Shift","OS"]
.filter(event.getModifierState, event).join(" ");
switch(event.keyCode) {
case KeyEvent.DOM_VK_F4:
if(modifiers == "Control") {
BrowserTryToCloseWindow();
event.preventDefault();
event.stopPropagation();
}
break;
}
},true); ]]></script>
</overlay>