Setting focus on input field, keyboard-only operability

Setting focus on input field, keyboard-only operability

Post by Hans-Georg » Mon, 12 Oct 2009 16:52:21


Am I right that the .focus() method always has two effects? It
can give the focus to an input field, but it also always gives
the focus to the browser window and moves it to the top. Are
these two effects inseparable?

My aim is to make web sites operable without a mouse, with the
keyboard only. That's usually a requirement for good user
interfaces.

The negative example is http://www.yqcomputer.com/ , where you cannot
easily get to the search input field without using the mouse. I
think that's a mistake from the point of view of user
interaction, because it requires changing from keyboard to
mouse, then back to keyboard, which is unnecessarily awkward and
time-consuming.

The positive counter-example would be http://www.yqcomputer.com/ ,
where the cursor appears in the all-important input field after
page loading.

So what are JavaScript programmers supposed to do? Simply set
the focus to the input field after the page is loaded? That's
what I would tend to do. Any traps along that road?

Hans-Georg
 
 
 

Setting focus on input field, keyboard-only operability

Post by Martin Hon » Tue, 13 Oct 2009 01:00:47


IE exposes a setActive method
http://www.yqcomputer.com/ (VS.85).aspx
that you can use instead of the focus method.

--

Martin Honnen
http://www.yqcomputer.com/

 
 
 

Setting focus on input field, keyboard-only operability

Post by Hans-Georg » Tue, 13 Oct 2009 01:16:50


Ah, thanks! I didn't know that.

However, this would not help with the other browsers. As far as
I understand, they would still set the focus to the desired
input element and at the same time to the entire window.

Well, if there is no browser-independent solution to that, then
user convenience will often dictate that the focus be set.

Hans-Georg