On Focus / On Input Events

On focus and on input events refer to interactive triggers that occur when a user selects or enters data into a form field, link, or control. These events can be activated by various methods such as mouse clicks, keyboard navigation, or assistive technologies and play a crucial role in web accessibility.

When a user moves focus onto an element (such as by pressing Tab), or changes its value (such as by typing or selecting an option), scripts may respond dynamically. For example, displaying a tooltip, opening a dropdown, or validating input automatically.

However, WCAG 3.2.1 (On Focus) and 3.2.2 (On Input) warn against triggering unexpected changes when these events occur. Automatically submitting a form or opening a new page when a field gains focus can disorient or confuse users, especially those using screen readers or keyboard navigation.

Developers should ensure that interactive changes are predictable and initiated only with explicit user action, such as pressing Enter or clicking a button.

Accessible outcome: Focus and input events behave predictably, allowing users to navigate, select, and enter information without triggering unexpected actions.