caret index to be updated only in keypress event