Made of Bugs

It's software. It's made of bugs.

Wordpress tricks: Disabling editing shortcuts

One of the major reasons I can’t stand webapps is because I’m a serious emacs junkie, and I can’t edit text in anything that doesn’t have decent emacs keybindings.

Fortunately, on Linux, at least, GTK provides basic emacs keybindings if you add

gtk-key-theme-name = "Emacs"

to your .gtkrc-2.0. However, some webapps think that they deserve total control over your keys, and grab key combinations for a WYSIWYG editor of some sort. And so whenever I try to edit a post in Wordpress (most of them are written in emacs and then copied over), I find myself trying to go backwards a word, and inserting random <strong> tags all over my post (Because M-b is bound to make text bold, by Wordpress’s editor). I finally got annoyed enough to do some source-diving, and discovered that Wordpress’s editor constructs keyboard shortcuts using the HTML accesskey attribute. This is easy enough to manipulate from Javascript, so I went and wrote up a quick Greasemonkey user script. The bulk of it is a simple XPath:

    var buttons = document.evaluate('//input[@type="button"][@accesskey]', poststuff);
    var button;

You can install the script off of nelhage.com.

Let me know if you find this useful, or if anyone figures out a general way to disable (sets of) keyboard shortcuts for websites, without relying on knowing the specific tricks that a website uses.