title: Get mouse position based on where user clicks
body: <p>I am trying to write a simple text editor in a browser. What I am currently stuck on is when a user clicks to change the mouse position, how can I get the index in the string of the new position?</p>
  <p><strong>Example:</strong></p>
  <p>User types:</p>
  <blockquote>
  <p>Hello World!</p>
  <p>My name is John.</p>
  </blockquote>
  <p>Currently cursor is after the period after John. What I would like to be able to do is get the index of the cursor when the user tries to append more after the ! in Hello World!.</p>
  <p>I am trying to do this to check for number of tabs currently used in the line so when the user presses enter, the correct number of tabs can be applied to the beginning of the string.</p>