I’m trying to bring the typing cursor to beginning of the input text by this code with no success. What is the issue?
HTML
<input value="text"/>
JavaScript(jQuery)
$('input').focus(function(){
$(this).delay(100).trigger(jQuery.Event("keydown",{keyCode: 36, which: 36}));
});
Live at JSBin
So, the problem is not really pressing home but moving cursor to beginning of the texbox I assune.
Checking this answer: move cursor to the beginning of the input field?
Generally the approach is right, but it doesn’t seem to work directly
I have modified it to fit your jQuery on focus case:
Live example:
http://jsfiddle.net/sF334/
If you want to trigger the focus itself, then you can do it as:
Note it returns to before the first character on focus, but allows you to move and change selection later as you wish, as soon as you change focus and come back, it’ll return to initial position again.