         if (isTextInputInFocus)
         {
             //trace("ComboBox.capture_keyDownHandler code",event.keyCode);
-            super.keyDownHandler(event);
+            keyDownHandlerHelper(event);
+        }
+    }
+    
+    /**
+     *  @private 
+     */ 
+    mx_internal function keyDownHandlerHelper(event:KeyboardEvent):void
+    {
+        super.keyDownHandler(event);
+        
+        if (event.keyCode == Keyboard.ENTER && !isDropDownOpen) 
+        {
+            // commit the current text
+            applySelection();
+        }
+        else if (event.keyCode == Keyboard.ESCAPE)
+        {
+            // Restore the previous selectedItem
+            textInput.text = itemToLabel(selectedItem);
         }
     }
     

    override public function setFocus():void
    {
        if (stage)
        {
            stage.focus = textInput.textDisplay;
            
            // Since the API ignores the visual editable and selectable 
            // properties make sure the selection should be set first.
            if (textInput.textDisplay && 
                (textInput.textDisplay.editable || textInput.textDisplay.selectable))
            {
                textInput.textDisplay.selectAll();
            }
        }
    }
    
    /**
     *  @private
     */
    override protected function isOurFocus(target:DisplayObject):Boolean
    {
        return target == textInput.textDisplay;
    }
    
    /**
     *  @private 
     */ 
    override protected function dropDownController_closeHandler(event:DropDownEvent):void
    {
        super.dropDownController_closeHandler(event);
        
        if (!event.isDefaultPrevented())
        {
            if (actualProposedSelectedIndex == CUSTOM_SELECTED_ITEM)
            {
                var itemFromInput:* = getCustomSelectedItem();
                if (itemFromInput != undefined)
                    selectedItem = itemFromInput;
                else
                    selectedIndex = NO_SELECTION;
            }
            else
            {
                selectedIndex = actualProposedSelectedIndex;
            }
        }
    }
    
    //--------------------------------------------------------------------------
    //
    //  Event Handlers
    //
    //--------------------------------------------------------------------------
    
    /**
     *  @private 
     */ 
    private function textInput_focusInHandler(event:FocusEvent):void
    {
        isTextInputInFocus = true;
    }
    
    /**
     *  @private 
     */ 
    private function textInput_focusOutHandler(event:FocusEvent):void
    {
        isTextInputInFocus = false;
    }
    
    /**
     *  @private 
     */ 
    protected function textInput_changeHandler(event:Event):void
    {   
        // Ignore the ENTER key
        /*if (isEnterKeyDown)
            return;*/
        //trace("CB.textInput_changeHandler");
        /* TODO (jszeto) Figure out how to find the new text
        
        Two ways of doing the interaction:
        
        1. DropDown shows set of possible choices  
        
        - Behavior as defined in XD spec
        - Create new function that takes an input string and returns the array of data items
        that match string
        - Figure out how to only display a subset of the dataProvider. Use collection filters?
        
        2. DropDown highlights first match
        
        - DropDown opens if we find a match
        - Match is highlighted, but not selected until Enter or mouse click selects the item
        - Can use arrows to change selection
        - Behavior of Halo ComboBox
        
        */
       
        
        // Open the dropDown if it isn't already open
        if (openOnInput)
        {
            if (!isDropDownOpen)
            {
                openDropDown();
                addEventListener(DropDownEvent.OPEN, editingOpenHandler);
                return;
            }   
            
            processInputField();
        }
    }
    
    /**
     *  @private 
     */ 
    private function editingOpenHandler(event:DropDownEvent):void
    {
        removeEventListener(DropDownEvent.OPEN, editingOpenHandler);
        processInputField();
    }
    
    
    
    
        
}
}
import flash.events.Event;
import flash.events.FocusEvent;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.ui.Keyboard;

import flashx.textLayout.operations.CutOperation;
import flashx.textLayout.operations.DeleteTextOperation;
import flashx.textLayout.operations.FlowOperation;
import flashx.textLayout.operations.InsertTextOperation;

import mx.core.mx_internal;
import mx.styles.StyleProxy;

import spark.components.supportClasses.ListBase;
import spark.core.NavigationUnit;
import spark.events.DropDownEvent;
import spark.events.TextOperationEvent;
import spark.utils.LabelUtil;
