optimised onFocusCaret for focus and caret tracking