Skip to content

jsx_a11y/mouse-events-have-key-events Correctness

This rule is turned on by default.

What it does

Enforce onmouseover/onmouseout are accompanied by onfocus/onblur.

Why is this bad?

Coding for the keyboard is important for users with physical disabilities who cannot use a mouse, AT compatibility, and screenreader users.

Example

Examples of incorrect code for this rule:

jsx
<div onMouseOver={() => void 0} />

Examples of correct code for this rule:

jsx
<div onMouseOver={() => void 0} onFocus={() => void 0} />

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny jsx-a11y/mouse-events-have-key-events --jsx-a11y-plugin
json
{
  "plugins": ["jsx-a11y"],
  "rules": {
    "jsx-a11y/mouse-events-have-key-events": "error"
  }
}

References

Released under the MIT License.