I have my own jquery keyboard that allow users to enter text into a textbox when each key is clicked. The problem is that the user cannot write in a specific position inside the word because of my current code:
HTML:
<input type="text" id="id">
<!--Some keys-->
<div id="k-e" class="key key-btn">e</div>
<div id="k-r" class="key key-btn">r</div>
<div id="k-t" class="key key-btn">t</div>
Jquery:
$("div.key").click(function(e){
var currentName = $("#name").val();
$("#name").val(currentName + $(this).text());
});
Right now, for example: If a user click before the letter "i" in "Maia" to write the letter "r", when the key is clicked the letter is entered, but at the end of the word.
Can someone please explain me how can I achieve this with jquery?