Handle ESC and ENTER keyboard events during editing.

Handle ESC and ENTER keyboard events during editing with expected behaviors.