The getSelection() method of the Document interface returns a Selection object representing the range of text selected by the user, or the current position of the caret.
getSelection()
external Selection? getSelection();