There are buttons of the "virtual keyboard", with the help of which the characters of another language are entered into the text fields, which the "average" user does not have on the keyboard.
Now it works as follows: when the text field loses focus, its id is stored in a variable, that is, the id of the last input in which the cursor was located in this variable. If the user now clicks on the buttons of the virtual keyboard, then the corresponding character is added to the end of this text field. It's simple...
But, let's say, the character needs to be added not to the end of the line in the field, but to the middle, i.e. the cursor in this field stood in the middle of the word. You can remember by focusout, along with the id field, in which position the cursor was in the field, but how to determine in which position in the text in the field is the cursor? Something I can not figure out, tell me, pliz :)