Is that the complete code? If it is you have a ways to go before your able to achieve your goals. return in a none function context… where did you pick that up.
Oh, side note – the empty array declaration before the getElements is pointless, and since all those if statements do the same thing off the same variable, you should be using case with drop-through instead of IF.
Also, I’d have to see the HTML this is being run upon, but if that anchor you’re looking for is the first child element of the LI, it may be more effective to do ‘firstChild’ instead of the rather slow (painfully slow in legacy browsers with shiv’s) getElementsByTagName.
Oh, and is it supposed to return null if enter is hit but the field is empty?
Hmm ok well I supposed I can remove the empty array declaration. Does having return false in a function do nothing? I don’t just want the firstchild either.
That should work – you’re just trapping the keyboard wrong and/or not enough. again, onkeyup and/or onkeypress and/or onsubmit if inside a form. onkeydown alone? Unlikely to work.
since you’re only pulling link[0] I’d assume there’s a fixed relationship.
But again, without seeing the FULL code, as in the HTML that’s being processed, the FULL scripting (lack of which is confusing Oddz and likely everyone else) including the METHOD of hooking the element you’re processing (are you adding it with javascript, are you doing it in the markup) … well… I have a saying, CSS without the HTML it’s applied to is gibberish; In this case javascript without the HTML it’s applied to is, well…