JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" placeholder="Type anything" style="font-size:14px">
<pre id="log"></pre>
JavaScript
const input = document.querySelector('input[type="text"]');
const logger = document.querySelector('#log');
function log() {
logger.innerText = `
selectionStart: ${input.selectionStart},
selectionEnd:${input.selectionEnd}
`;
}
input.addEventListener( 'focus', log, false );
input.addEventListener( 'keyup', log, false );