Lint Rules

noAccessKey (since v11.0.0)

This rule is recommended by Rome.

Enforce that the accessKey attribute is not used on any HTML element.

The accessKey assigns a keyboard shortcut to the current element. However, the accessKey value can conflict with keyboard commands used by screen readers and keyboard-only users, which leads to inconsistent keyboard actions across applications. To avoid accessibility complications, this rule suggests users remove the accessKey attribute on elements.

Examples

Invalid

<input type="submit" accessKey="s" value="Submit" />
nursery/noAccessKey.js:1:22 lint/nursery/noAccessKey  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Avoid the accessKey attribute to reduce inconsistencies between keyboard shortcuts and screen reader keyboard comments.
  
  > 1 │ <input type="submit" accessKey="s" value="Submit" />
                        ^^^^^^^^^^^^^
    2 │ 
  
   Assigning keyboard shortcuts using the accessKey attribute leads to inconsistent keyboard actions across applications.
  
   Suggested fix: Remove the accessKey attribute.
  
    1 │ <input·type="submit"·accessKey="s"·value="Submit"·/>
                       --------------                 
<a href="https://webaim.org/" accessKey="w">WebAIM.org</a>
nursery/noAccessKey.js:1:31 lint/nursery/noAccessKey  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Avoid the accessKey attribute to reduce inconsistencies between keyboard shortcuts and screen reader keyboard comments.
  
  > 1 │ <a href="https://webaim.org/" accessKey="w">WebAIM.org</a>
                                 ^^^^^^^^^^^^^
    2 │ 
  
   Assigning keyboard shortcuts using the accessKey attribute leads to inconsistent keyboard actions across applications.
  
   Suggested fix: Remove the accessKey attribute.
  
    1 │ <a·href="https://webaim.org/"·accessKey="w">WebAIM.org</a>
                                -------------               
<button accessKey="n">Next</button>
nursery/noAccessKey.js:1:9 lint/nursery/noAccessKey  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Avoid the accessKey attribute to reduce inconsistencies between keyboard shortcuts and screen reader keyboard comments.
  
  > 1 │ <button accessKey="n">Next</button>
           ^^^^^^^^^^^^^
    2 │ 
  
   Assigning keyboard shortcuts using the accessKey attribute leads to inconsistent keyboard actions across applications.
  
   Suggested fix: Remove the accessKey attribute.
  
    1 │ <button·accessKey="n">Next</button>
          -------------              

Resources