Link to home
Create AccountLog in
Avatar of Pete C
Pete CFlag for United States of America

asked on

when should you set access keys within form controls, if at all

I am trying to determine if it is necessary/good practice to set access keys within form controls.  I am not entirely clear where it would be helpful.  i.e. do you have any thoughts as to where it may be useful, and whether setting the tab order is also something that deserves consideration.

on a related note, when I launch a form (that I have created), I first need to click on the form before I can tab to the first control.  Is there a way to activate the form, such that when I press tab it goes to the first control (without needing to first click on the form)?

Avatar of gr8gonzo
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Pete C


thanks for the insights; relative to tab order, I generate the controls dynamically, so the scenario that you mentioned does not currently present an issue, but I will keep your thoughts in mind.

relative to access keys, I can see your point.  With respect to my efforts, the forms are all fairly short, so I am not sure that displaying an access key (so users can then use it), would yield any significant benefits, but relative to your example, I can see where they would be helpful.

to confirm, when you refer to focus, are you referring to setting it via js such as below:

Thanks again!

I'm sorry - I read "form controls" and I automatically thought you were talking about Windows Forms controls (C# / .NET). I made the mistake of not reading the topic zones.

The same principles still apply, though - just some slight syntax differences. 

On a couple of customers pages, I have had to remove the tab order because it was created manually and then the form changed without re-doing the tab order.  If you can do it programmatically so it is always right, that could be a good thing.

Avatar of Pete C


thanks, I could do that (set the tab order dynamically), but I have not noticed any issue with the default order, i.e. it tabs from left to right and then down, so currently it does not seem necessary
Avatar of Pete C


to confirm, am I correct in assuming that you should always define the focus state for buttons such that users can always see visually that something has the focus.  i.e. the display changes each time they press tab

The default styles should already have focus indicators. You should only need to define a :focus style when you want to override that, but I wouldn't recommend doing that unless the defaults aren't doing something that you need.