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