Do you guys know any drawback of focusing on a text field on a web page ? It's pretty useful when you know users will use this text field more than others (like on the google homepage), but it's a bit "offensive", so I wondered if there's something bad that could happen (on mobile devices for example)
Normally the Backspace key takes you back a page as it is a keyboard shortcut for the Back button. When an input field is focused, the backspace only works within the input field. For many keyboard users (as in prefer the keyboard and avoid switching between keyboard and mouse) it therefore is a definite drawback when a site auto focuses an input field arbitrarily.
That said, I do not like pages not to auto focus on the first field when the whole purpose of the page is to fill out a form and submit it.
So I guess basically the rule for me would be: auto focus for data-entry forms; do not auto focus when input is a secondary (or even lower) item on a page.
The following is not an inherent drawback of setting the keyboard focus, but anyway an undesired effect which was caused by a combination of a focus-setting script and the behavior of certain browsers.
At least in Firefox, setting the keyboard focus can steal the focus even from the UI element belonging to the browser itself such as the address bar. Because of this, I have experienced the following small annoyance:
- I visited some page. The page contained an onload script to set the focus to a particular textbox, but naturally I did not know that.
- The page took too long to load, so I gave up visiting that page and decided to visit some other page.
- I started typing a new URL in the address bar.
- Meanwhile the page finished loading and the script inside the page ran.
- The latter half of the address I typed ended up in the textbox on the page, which was a slight frustration. :(
(In Firefox 4, it is planned to avoid this behavior by disallowing the page content from retrieving the focus when the browser UI element has the focus (the fix has been partly committed but not completely). If this fix goes in, the situation stated above will not happen with Firefox 4. I hear that Internet Explorer does not have the same problem.)
Putting the focus into a text field when the page loads prevents the up/down arrows for scrolling the page, meaning that users have to click on the page to get it to scroll. However, if the page doesn't scroll, or has only one action that requires the text box, it can be very useful.
My online banking site has several text boxes for entering specific characters from my password and pin number. When a key is pressed, the page auto-focuses the next text box. This is good normally because it means you don't have to tab between controls, but is a real pain when you accidentally type the wrong character. In this case, it breaks shift+tab behaviour - pressing shift+tab takes you back a control, but releasing shift takes you forward again meaning that you have to reach for the mouse.
Autofocus can sometimes cause problems to plugins like Vivium (which add Vim-like shortcuts to Google Chrome) as it automatically puts Vimium in insert mode, which makes navigation more difficult.
There are lots of great answers here already, but no-one has mentioned how to mitigate problems associated with auto-focus. I would advise, as an absolute minimum, that you very clearly style the auto-focussed element so that it's more obvious that it's active. The blinking cursor should be a pretty good indication, but you can be much more obvious with a thick, coloured border or similar.
Offensive may not be the right term, but it's definitely rude. I put auto-focus up there with auto-play of music or auto-launching of pop-up windows or auto-resizing of my browser. It takes control away from the user and, IMHO, that is always rude. Not to mention issues already mentioned like usability on mobile devices or accessibility in general.
Ultimately it's going to depend on what your web site does and the consequences of being focused on this area.
If your site only has the one input field (like Google) and another action is required to act on this input then I can't see a problem. It's what people will (come to) expect and if anything it helps them use the site.
If it's only one of several text fields and could be left blank then it's probably less of a user aide and might tip over to a hindrance for a significant number of users.
If you do something after every keystroke then I could see it as being an annoyance - but that's largely personal preference.
Real life example: Wordpress ruined my login routine with autofocus since wp 2.9 or something.
Before they inserted the autofocus, i'd hit the bookmark, click login with the user/pass stored on the browser and BAM!, i was in.
Now, autofocus clears my browser stored data and i have to write the username, hit tab to get the autocomplete for the password and than enter. A lot more steps.
Auto-focus is a big no-no on login pages.
People like me have a habit of entering username and password as soon as the textboxes are visible. Sometimes, what happens is that the page finishes loading when I'm in the middle of entering my password, causing the focus to go to the username textbox and then I end up typing the rest of my password into the username field.
This is a big nuisance and websites should avoid using auto-focus on such pages.