I would like to know if there are possible to know at which position of the input value is at when pressing a key.
Say I have a text field.
<input id="name" type="text">
And I want to to something if the right-arrow-key is pressed only if they are at the end of the string, and I want something else if the left-arrow-key is pressed if they are at the beginning of the input value. I want to be able to something like this:
$("#name").keyup( function(e) {
if( e.which === 37 ) { // left
if( isAtBeginningOfInputValue ) {
// Do something
}
} else if( e.which === 39 ) { // right
if( isAtEndOfInputValue ) {
// Do something else
}
}
});
Is this possible?