The behavior of the caret changes depending on if there is a selection or not when: a character is input; backspace key is pressed; delete button is pressed. It's also used in determining the value of isKeyDelete.