The keyboard shortcuts command+shift+z and ctrl+shift+z for redo in text input boxes don't work. The shortcuts command+y and ctrl+y work correctly, but aren't the standard on OS X.

Undo works (with different scope than native undo), but not redo. Clicking the redo button works, but the keyboard shortcut doesn't.

Having a way to turn off SO's keyboard shortcuts would fix this problem, as undo and redo work fine in text inputs when not hijacked.

I found myself writing up a bug report about redo not working only to have the top suggestion be... my own bug report about redo not working!

Since then, another bug occasioned me to delve into wmd.js and see that this appears to be decidedly unintended behavior. Here's what appears to be the relevant (de-minified) section of the code:

function (a) {
    var b = !1;
    if (a.ctrlKey || a.metaKey) switch (String.fromCharCode(a.charCode || a.keyCode)) {
    case "y":
        b = !0;
    case "z":
        a.shiftKey ? d.redo() : d.undo(), b = !0

That last a.shiftKey ? d.redo() : d.undo() clause looks very much like an effort to redo() when shift is pressed in combination with the undo() keyboard shortcut.

So here's some more information about this apparently clear, if clearly low-priority bug. We'll see if it does any better after this bump.

  • 2
    +1 for having a way to turn off shortcuts. I would rather the browser itself deal with some things.
    – cdeszaq
    Feb 10, 2012 at 14:42

2 Answers 2


This is fixed now, sorry about that. (The fix will be in the next build of the sites).

Regarding this:

undo and redo work fine in text inputs when not hijacked.

– unfortunately that's not quite as easy. I'm the first to concede that using a browser's native functionality is better than rolling your own. The problem is that the editor programmatically changes the content of the input area (e.g. on click of a button), and native undo/redo doesn't handle those changes.

There is work being done on finding a way to expose the native undo/redo stack to JavaScript, but that's far from existing.

However when looking into this, I found the execCommand API, which is originally an IE invention, but seems to have some decent browser support these days. Some initial testing suggests that it may be something to work with (possibly with some caveats) in order to make it possible to leave undo/redo to the user agent. I can't promise anything, but I'll do some research and testing.


For the sake of anyone else running into this problem (as it appears unlikely to be fixed), here's the user script that I ended up with to disable all WMD shortcut keys:

// ==UserScript==
// @name           Cya WMD shortcuts
// @namespace      Rob W
// @version        1.0
// @run-at         document-end
// @description   A hook to disable WMD keyboard shortcuts
// @match       http://stackoverflow.com/*
// @match       http://meta.stackoverflow.com/*
// @match       http://superuser.com/*
// @match       http://meta.superuser.com/*
// @match       http://serverfault.com/*
// @match       http://meta.serverfault.com/*
// @match       http://askubuntu.com/*
// @match       http://meta.askubuntu.com/*
// @match       http://answers.onstartups.com/*
// @match       http://meta.answers.onstartups.com/*
// @match       http://stackapps.com/*
// @match       http://*.stackexchange.com/*
// @exclude       http://chat.stackexchange.com/*
// @exclude       http://chat.*.stackexchange.com/*
// @exclude       http://api.*.stackexchange.com/*
// @exclude       http://data.stackexchange.com/*
// @exclude       http://*/reputation
// ==/UserScript==

(function() {
    var p = document.getElementById('wmd-input').parentNode;
    function ignore(e){(e.metaKey || e.ctrlKey) && e.stopPropagation();}    
    p.addEventListener('keydown', ignore, true);
    p.addEventListener('keypress', ignore, true);
    p.addEventListener('keyup', ignore, true);

This is a modification of Rob W's original script, updated for Chrome and to avoid triggering the captcha all the time because no events go through.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .