Give focus to an element on startup - or don't?

otacke's picture
Forums: 

What's the suggested behavior for giving focus to an element on startup?

I added additional key support to Agamotto. You can now use the left key and the right key to jump from one image to another IF you clicked on the images before or jumped to them using the tab key. I don't focus the content or controls on startup since that's the way that Course Presentation and Interactive Video behave, too. However, some people mentioned that this might be rather uncomfortable and counterintuitive.

Is there a general (web accessibility) rule that applies?

thomasmars's picture

Guideline 2.1.1 in WCAG 2.0 says 

All functionality of the content is operable through a keyboard interface without requiring specific timings for individual keystrokes, except where the underlying function requires input that depends on the path of the user's movement and not just the endpoints.

Setting focus on startup of an H5P could introduce some timing issues, which must be avoided. We don't know the context of the H5P that just finished loading so the user could be in the middle of another process.

When we know the action of the user, e.g. changing image to one that is just created, it is perfectly fine, even encouraged to move focus to the new element that was navigated to (if it has an action). We should attempt to make as intuitive navigation as possible. If it makes sense that a H5P spawned from another process should get focus it should be up to the process/function that spawned it to make sure that focus is moved correctly to the H5P on startup.

otacke's picture

Alright. Thanks!