Index: src/wp-includes/js/quicktags.js
===================================================================
--- src/wp-includes/js/quicktags.js	(revision 31798)
+++ src/wp-includes/js/quicktags.js	(working copy)
@@ -150,7 +150,8 @@
 			zeroise( now.getUTCSeconds() ) +
 			'+00:00';
 	})(),
-	qt;
+	qt,
+	keyboardSelectionIE = false;
 
 	qt = QTags = function(settings) {
 		if ( typeof(settings) === 'string' ) {
@@ -220,6 +221,12 @@
 			tb.attachEvent('onclick', onclick);
 		}
 
+		if ( canvas.addEventListener ) {
+			canvas.addEventListener( 'keydown', qt.OnTab, false );
+		} else if ( canvas.attachEvent ) {
+			canvas.attachEvent( 'onkeydown', qt.OnTab );
+		}
+
 		t.getButton = function(id) {
 			return t.theButtons[id];
 		};
@@ -243,7 +250,7 @@
 	};
 
 	qt._buttonsInit = function() {
-		var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use,
+		var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use, closeAllButton,
 			defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
 
 		for ( inst in t.instances ) {
@@ -299,6 +306,13 @@
 			}
 
 			ed.toolbar.innerHTML = html;
+
+			// Disable the Close All button on init.
+			closeAllButton = document.getElementById( ed.name + '_' + theButtons.close.id );
+			if ( closeAllButton ) {
+				closeAllButton.setAttribute( 'disabled', 'disabled' );
+			}
+
 			ed.theButtons = theButtons;
 
 			if ( typeof jQuery !== 'undefined' ) {
@@ -439,11 +453,18 @@
 	};
 	qt.TagButton.prototype = new qt.Button();
 	qt.TagButton.prototype.openTag = function(e, ed) {
-		var t = this;
+		var t = this,
+			closeAllButton = document.getElementById( ed.name + '_' + ed.theButtons.close.id );
 
+		// Enable the Close All button now that we have open tags.
+		if ( closeAllButton ) {
+			closeAllButton.removeAttribute( 'disabled' );
+		}
+
 		if ( ! ed.openTags ) {
 			ed.openTags = [];
 		}
+
 		if ( t.tagEnd ) {
 			ed.openTags.push(t.id);
 			e.value = '/' + e.value;
@@ -450,12 +471,20 @@
 		}
 	};
 	qt.TagButton.prototype.closeTag = function(e, ed) {
-		var t = this, i = t.isOpen(ed);
+		var t = this, i = t.isOpen(ed),
+			closeAllButton = document.getElementById( ed.name + '_' + ed.theButtons.close.id );
 
 		if ( i !== false ) {
 			ed.openTags.splice(i, 1);
 		}
 
+		// Disable the Close All button when there are no more open tags.
+		if ( 0 === i && closeAllButton ) {
+			closeAllButton.setAttribute( 'disabled', 'disabled' );
+		}
+		// Handle focus when the Close All button gets disabled.
+		ed.canvas.focus();
+
 		e.value = t.display;
 	};
 	// whether a tag is open or not. Returns false if not open, or current open depth of the tag
@@ -476,7 +505,8 @@
 
 		if ( document.selection ) { // IE
 			canvas.focus();
-			sel = document.selection.createRange();
+			// Check if we already have an IE keyboard selection first.
+			sel = keyboardSelectionIE || document.selection.createRange();
 			if ( sel.text.length > 0 ) {
 				if ( !t.tagEnd ) {
 					sel.text = sel.text + t.tagStart;
@@ -494,6 +524,8 @@
 					t.closeTag(element, ed);
 				}
 			}
+			// Reset IE keyboard selection
+			keyboardSelectionIE = false;
 			canvas.focus();
 		} else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera
 			startPos = canvas.selectionStart;
@@ -544,6 +576,18 @@
 		}
 	};
 
+	// IE keyboard selection: get and store the selection when reverse tabbing.
+	qt.OnTab = function( event ) {
+		var key;
+
+		if ( document.selection && 'keydown' === event.type ) {
+			key = event.keyCode || event.charCode;
+			if ( event.shiftKey && 9 === key ) {
+				keyboardSelectionIE = document.selection.createRange();
+			}
+		}
+	};
+
 	// removed
 	qt.SpellButton = function() {};
 
