I had installed RobW's script to disable the hotkeys in the SO editor, but it does not work anymore. Here is a different script that disables specific keys for all elements in the document. I have put the 4 emacs bindings that are overridden by the SO editor (WMD), but other shortcuts should be added for MacOS users with muscle memory.
I got the idea from http://blog.rodneyrehm.de/archives/23-Reclaim-Your-Keyboard-Shortcuts-in-Firefox.html
Install as a User Script:
// ==UserScript==
// @name OSX shortcut disabler
// @namespace chqrlie
// @version 1.0
// @match https://stackoverflow.com/*
// @match https://*.stackoverflow.com/*
// @match https://superuser.com/*
// @match https://meta.superuser.com/*
// @match https://serverfault.com/*
// @match https://meta.serverfault.com/*
// @match https://askubuntu.com/*
// @match https://meta.askubuntu.com/*
// @match https://*.stackexchange.com/*
// @match https://mathoverflow.net/*
// @match https://*.mathoverflow.net/*
// @match https://stackapps.com/*
// @run-at document-end
// @grant none
// ==/UserScript==
(typeof unsafeWindow !== 'undefined' ? unsafeWindow : window).$(function() {
document.addEventListener('keydown', function(e) {
// Prevent propagation of emacs key bindings
if (e.ctrlKey) {
switch (e.keyCode) {
case 0x42: // ^B backward-char
case 0x49: // ^I indent-line
case 0x4B: // ^K kill-line
case 0x59: // ^Y yank
e.stopImmediatePropagation();
return;
}
}
}, true);
});
Install as a Chrome extension:
- Create a directory, and store the following two files in it.
- Visit chrome://extensions/
- Enable Developer mode
- Click on the button Load unpacked extension....
- Select the directory from step 1.
manifest.json
{
"name": "Chqrlie shortcut disabler",
"manifest_version": 2,
"version": "1.0",
"content_scripts": [{
"js": ["contentscript.js"],
"matches": [
"https://stackoverflow.com/*",
"https://*.stackoverflow.com/*",
"https://superuser.com/*",
"https://meta.superuser.com/*",
"https://serverfault.com/*",
"https://meta.serverfault.com/*",
"https://askubuntu.com/*",
"https://meta.askubuntu.com/*",
"https://*.stackexchange.com/*",
"https://mathoverflow.net/*",
"https://*.mathoverflow.net/*",
"https://stackapps.com/*"
]
}]
}
contentscript.js
document.addEventListener('keydown', function(e) {
// Prevent propagation of emacs key bindings
if (e.ctrlKey) {
switch (e.keyCode) {
case 0x42: // ^B backward-char
case 0x49: // ^I indent-line
case 0x4B: // ^K kill-line
case 0x59: // ^Y yank
e.stopImmediatePropagation();
return;
}
}
}, true);
@
on a German keyboard is Ctrl+Alt+q which the StackOverflow editor interprets as Ctrl+q, or blockquote. It is simply impossible to type an@
sign into the SO editor with a German keyboard layout. My "fix"? Spend 1500€ on a Mac, where the@
sign lives on a different key. (Well, I admit, that wasn't the reason I bought it, but it was a nice side-effect.)