Skip to content
← Back to rules

jsx-a11y/no-access-key Correctness

💡 A suggestion is available for this rule.

What it does ​

Enforces that the accessKey prop is not used on any element to avoid complications with keyboard commands used by a screen reader.

Why is this bad? ​

Access keys are HTML attributes that allow web developers to assign keyboard shortcuts to elements. Inconsistencies between keyboard shortcuts and keyboard commands used by screen readers and keyboard-only users create accessibility complications so to avoid complications, access keys should not be used.

Examples ​

Examples of incorrect code for this rule:

jsx
<div accessKey="h" />

Examples of correct code for this rule:

jsx
<div />

How to use ​

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

json
{
  "plugins": ["jsx-a11y"],
  "rules": {
    "jsx-a11y/no-access-key": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["jsx-a11y"],
  rules: {
    "jsx-a11y/no-access-key": "error",
  },
});
bash
oxlint --deny jsx-a11y/no-access-key --jsx-a11y-plugin

Version ​

This rule was added in v0.0.21.

References ​