Index: /CKEditor/branches/versions/3.6.x/CHANGES.html
===================================================================
--- /CKEditor/branches/versions/3.6.x/CHANGES.html	(revision 6681)
+++ /CKEditor/branches/versions/3.6.x/CHANGES.html	(revision 6682)
@@ -43,4 +43,5 @@
 		<li><a href="http://dev.ckeditor.com/ticket/5745">#5745</a> : Allow to pass extra configuration options for iframeDialog.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/7240">#7240</a> : Added the Developer Tools (<code>devtools</code>) plugin that shows information about dialog window UI elements to allow for easier customization.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/6841">#6841</a> : Enter key at the end of pre-formatted block will exit from it.</li>
 	</ul>
 	<p>
Index: /CKEditor/branches/versions/3.6.x/_source/core/dom/range.js
===================================================================
--- /CKEditor/branches/versions/3.6.x/_source/core/dom/range.js	(revision 6681)
+++ /CKEditor/branches/versions/3.6.x/_source/core/dom/range.js	(revision 6682)
@@ -360,5 +360,5 @@
 			{
 				// If there's any visible text, then we're not at the start.
-				if ( CKEDITOR.tools.trim( node.getText() ).length )
+				if ( node.hasAscendant( 'pre' ) || CKEDITOR.tools.trim( node.getText() ).length )
 					return false;
 			}
Index: /CKEditor/branches/versions/3.6.x/_source/plugins/enterkey/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.6.x/_source/plugins/enterkey/plugin.js	(revision 6681)
+++ /CKEditor/branches/versions/3.6.x/_source/plugins/enterkey/plugin.js	(revision 6682)
@@ -32,10 +32,12 @@
 			var doc = range.document;
 
+			var atBlockStart = range.checkStartOfBlock(),
+				atBlockEnd = range.checkEndOfBlock(),
+				path = new CKEDITOR.dom.elementPath( range.startContainer ),
+				block = path.block;
+
 			// Exit the list when we're inside an empty list item block. (#5376)
-			if ( range.checkStartOfBlock() && range.checkEndOfBlock() )
-			{
-				var path = new CKEDITOR.dom.elementPath( range.startContainer ),
-						block = path.block;
-
+			if ( atBlockStart && atBlockEnd )
+			{
 				if ( block && ( block.is( 'li' ) || block.getParent().is( 'li' ) ) )
 				{
@@ -44,4 +46,7 @@
 				}
 			}
+			// Don't split <pre> if we're in the middle of it, act as shift enter key.
+			else if ( !atBlockEnd && block.is( 'pre' ) )
+				return enterBr( editor, mode, range, forceMode );
 
 			// Determine the block element to be used.
@@ -108,5 +113,6 @@
 					// a Shift+Enter (#77). Create a new block element instead
 					// (later in the code).
-					if ( previousBlock.is( 'li' ) || !headerTagRegex.test( previousBlock.getName() ) )
+					if ( previousBlock.is( 'li' ) ||
+							! ( headerTagRegex.test( previousBlock.getName() ) || previousBlock.is( 'pre' ) ) )
 					{
 						// Otherwise, duplicate the previous block.
@@ -337,12 +343,5 @@
 		// 1. We want to enforce the mode to be respected, instead
 		// of cloning the current block. (#77)
-		// 2. Always perform a block break when inside <pre> (#5402).
-		if ( editor.getSelection().getStartElement().hasAscendant( 'pre', true ) )
-		{
-			setTimeout( function() { enterBlock( editor, editor.config.enterMode, null, true ); }, 0 );
-			return true;
-		}
-		else
-			return enter( editor, editor.config.shiftEnterMode, 1 );
+		return enter( editor, editor.config.shiftEnterMode, 1 );
 	}
 
@@ -362,5 +361,5 @@
 			{
 				editor.fire( 'saveSnapshot' );	// Save undo step.
-				if ( mode == CKEDITOR.ENTER_BR || editor.getSelection().getStartElement().hasAscendant( 'pre', 1 ) )
+				if ( mode == CKEDITOR.ENTER_BR )
 					enterBr( editor, mode, null, forceMode );
 				else
