# Disabling accesskeys (shortcuts) in WordPress

OS X comes standard with many Emacs keybindings (**Ctrl-A** to move the
cursor to the start of the line, **Ctrl-E** to go to the end, **Ctrl-N**
and **Ctrl-P** for next and previous line, etc.), and since I’ve been
using these keybindings for about 15 years it’s pretty difficult to not
hit, say, **Ctrl-P** when it happens to conflict with WordPress’s
shortcut to publish a post… This is pretty much guaranteed to happen at
least once whilst writing a post, so this needed to be fixed.

There’s no configuration option to turn this off, and `accesskey="p"` is
buried in the HTML source and I couldn’t figure out a way to filter it
out—so the only thing left is JavaScript.

The fix I came up with is below; I’m just dumping this here instead of
packaging it up because I haven’t tested it on IE and it doesn’t work at
all on Firefox (though see below for a solution for Firefox). You
basically need a plugin like this:

    function disable_accesskeys() {
        ?>
            &lt;script type="text/javascript"&gt;
            jQuery(function () {
            var l = document.getElementsByTagName("input");
            for (var i = 0; i < l.length; i++) {
                if (l[i].accessKey) l[i].accessKey = '';
            }
            });
            &lt;/script&gt;
        &lt;?php
    }

    add_filter('admin_head', 'disable_accesskeys');

Note: for some reason this doesn’t work with Firefox. (Though neither
does [Wikipedia’s JavaScript
solution](http://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-removeAccessKeys.js&action=raw&ctype=t%0Aext/javascript),
upon which this is based.) However, there’s a better solution for
Firefox: you can disable access keys/shortcuts completely by setting the
[ui.key.contentAccess](http://kb.mozillazine.org/Ui.key.contentAccess)
(access via <about:config>) preference to 0 (i.e. zero). (Is there an
equivalent for Safari?)

Access keys are a bit of a failure, I think. They’re not consistent, not
transparent (you don’t know what’s going to happen before hitting a
combination), and they can conflict with whatever bindings your users
might be using already.

---

Turns out that the original Emacs keybindings were fixed the way they
are because, when Guy Steele was putting them together, about 20 people
at the AI lab at MIT were already using Emacs, and so he couldn’t change
the bindings without [alienating existing
users](http://groups.google.com/group/comp.lang.lisp/msg/0342e0bc1aa05c0d)…

A few years ago I [asked Google
answers](http://answers.google.com/answers/threadview?id=425239) for a
good, authoritative, durable reference for Emacs keybindings (I wanted
to pass this on to people) and didn’t get any good replies. I wonder if
one exists now?

Final Emacs keybinding-related note: on OS X, putting
[DefaultKeyBinding.dict](/stuff/mac/DefaultKeyBinding.dict) in
`~/Library/KeyBindings` makes a whole lot more Emacs keybindings
available, as well as making Home and End work the way they do on
Windows. (i.e. move cursor to the beginning and end of the line.)
