use cursor-position instead of selectionStart