Index: CKEditor/trunk/_source/plugins/dialog/plugin.js
===================================================================
--- CKEditor/trunk/_source/plugins/dialog/plugin.js	(revision 7477)
+++ CKEditor/trunk/_source/plugins/dialog/plugin.js	(revision 7516)
@@ -142,5 +142,5 @@
 			tabsToRemove = {},
 			i,
-			processed;
+			processed, stopPropagation;
 
 			if ( ( buttonsOrder == 'OS' && CKEDITOR.env.mac ) ||    // The buttons in MacOS Apps are in reverse order (#4750)
@@ -398,5 +398,5 @@
 
 
-		function focusKeydownHandler( evt )
+		function keydownHandler( evt )
 		{
 			// If I'm not the top dialog, ignore.
@@ -405,7 +405,9 @@
 
 			var keystroke = evt.data.getKeystroke(),
-				rtl = editor.lang.dir == 'rtl';
-
-			processed = 0;
+				rtl = editor.lang.dir == 'rtl',
+				button;
+
+			processed = stopPropagation = 0;
+
 			if ( keystroke == 9 || keystroke == CKEDITOR.SHIFT + 9 )
 			{
@@ -451,15 +453,43 @@
 				processed = 1;
 			}
-
+			// If user presses enter key in a text box, it implies clicking OK for the dialog.
+			else if ( keystroke == 13 /*ENTER*/ )
+			{
+				// Don't do that for a target that handles ENTER.
+				var target = evt.data.getTarget();
+				if ( !target.is( 'a', 'button', 'select' ) && ( !target.is( 'input' ) || target.$.type != 'button' ) )
+				{
+					button = this.getButton( 'ok' );
+					button && CKEDITOR.tools.setTimeout( button.click, 0, button );
+					processed = 1
+				}
+				stopPropagation = 1; // Always block the propagation (#4269)
+			}
+			else if ( keystroke == 27 /*ESC*/ )
+			{
+				button = this.getButton( 'cancel' );
+
+				// If there's a Cancel button, click it, else just fire the cancel event and hide the dialog.
+				if ( button )
+					CKEDITOR.tools.setTimeout( button.click, 0, button );
+				else
+				{
+					if ( this.fire( 'cancel', { hide : true } ).hide !== false )
+						this.hide();
+				}
+				stopPropagation = 1; // Always block the propagation (#4269)
+			}
+			else
+				return;
+
+			keypressHandler( evt );
+		}
+
+		function keypressHandler( evt )
+		{
 			if ( processed )
-			{
-				evt.stop();
-				evt.data.preventDefault();
-			}
-		}
-
-		function focusKeyPressHandler( evt )
-		{
-			processed && evt.data.preventDefault();
+				evt.data.preventDefault(1);
+			else if ( stopPropagation ) 
+				evt.data.stopPropagation();
 		}
 
@@ -468,16 +498,17 @@
 		this.on( 'show', function()
 			{
-				dialogElement.on( 'keydown', focusKeydownHandler, this, null, 0 );
+				dialogElement.on( 'keydown', keydownHandler, this );
+
 				// Some browsers instead, don't cancel key events in the keydown, but in the
-				// keypress. So we must do a longer trip in those cases. (#4531)
-				if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
-					dialogElement.on( 'keypress', focusKeyPressHandler, this );
+				// keypress. So we must do a longer trip in those cases. (#4531,#8985)
+				if ( CKEDITOR.env.opera || CKEDITOR.env.gecko )
+					dialogElement.on( 'keypress', keypressHandler, this );
 
 			} );
 		this.on( 'hide', function()
 			{
-				dialogElement.removeListener( 'keydown', focusKeydownHandler );
-				if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
-					dialogElement.removeListener( 'keypress', focusKeyPressHandler );
+				dialogElement.removeListener( 'keydown', keydownHandler );
+				if ( CKEDITOR.env.opera || CKEDITOR.env.gecko )
+					dialogElement.removeListener( 'keypress', keypressHandler );
 
 				// Reset fields state when closing dialog.
@@ -487,5 +518,5 @@
 			{
 				var doc = new CKEDITOR.dom.document( evt.data.iframe.$.contentWindow.document );
-				doc.on( 'keydown', focusKeydownHandler, this, null, 0 );
+				doc.on( 'keydown', keydownHandler, this, null, 0 );
 			} );
 
@@ -816,22 +847,4 @@
 			element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler );
 
-			// Prevent some keys from bubbling up. (#4269)
-			for ( var event in { keyup :1, keydown :1, keypress :1 } )
-				element.on( event, preventKeyBubbling );
-
-			// Register the Esc hotkeys.
-			registerAccessKey( this, this, '\x1b', null, function()
-					{
-						var button = this.getButton( 'cancel' );
-						// If there's a Cancel button, click it, else just fire the cancel event and hide the dialog
-						if ( button )
-							button.click();
-						else
-						{
-							if ( this.fire( 'cancel', { hide : true } ).hide !== false )
-								this.hide();
-						}
-					} );
-
 			// Reset the hasFocus state.
 			this._.hasFocus = false;
@@ -979,8 +992,4 @@
 				element.removeListener( 'keydown', accessKeyDownHandler );
 				element.removeListener( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler );
-
-				// Remove bubbling-prevention handler. (#4269)
-				for ( var event in { keyup :1, keydown :1, keypress :1 } )
-					element.removeListener( event, preventKeyBubbling );
 
 				var editor = this._.editor;
@@ -2200,12 +2209,4 @@
 	};
 
-	// ESC, ENTER
-	var preventKeyBubblingKeys = { 27 :1, 13 :1 };
-	var preventKeyBubbling = function( e )
-	{
-		if ( e.data.getKeystroke() in preventKeyBubblingKeys )
-			e.data.stopPropagation();
-	};
-
 	(function()
 	{
