1

hey guys, i have the following case: http://jsfiddle.net/cKf5b/

as you can see when you focus the textfield and you press the UP and DOWN arrow keys you can navigate through the list-items underneath.

i have the following line

        //set cursor position
        if(keyCode === 38) return false;

in order to keep the cursor position at the end of the text even when pressing the UP key.

I wonder if there is a better way to keep the cursor always at the end of the inputfield. Right now you can see it flicker when you press the UP key. The cursor jumps to the front and then gets set to the end.

any idea how i can stop that flickering?

matt
  • 42,713
  • 103
  • 264
  • 397
  • You might want to check this question out: http://stackoverflow.com/questions/1080532/prevent-default-behavior-in-text-input-while-pressing-arrow-up – Aleksi Yrttiaho Feb 10 '11 at 19:20
  • thank you, but i have no idea how i can implement that into my example! would appreciate any help, thank you! – matt Feb 10 '11 at 20:07

1 Answers1

3

try adding this code at the end :

$('.s').bind('keydown keypress',function(e)
{
    if (e.keyCode == 38 || e.keyCode == 40) 
    {
        e.preventDefault();
    }
});

or u can check it in jsfiddle : http://jsfiddle.net/cKf5b/12/

Shlomi Komemi
  • 5,445
  • 3
  • 28
  • 41