set caret position after press up/down