useKeyWithClickEvents
Este conteúdo não está disponível em sua língua ainda.
Diagnostic Category: lint/a11y/useKeyWithClickEvents
Since: v1.0.0
Sources:
Enforce onClick is accompanied by at least one of the following: onKeyUp
, onKeyDown
, onKeyPress
.
Coding for the keyboard is important for users with physical disabilities who cannot use a mouse, AT compatibility, and screenreader users. This does not apply for interactive or hidden elements.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.jsx:1:1 lint/a11y/useKeyWithClickEvents ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.
> 1 │ <div onClick={() => {}} />
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.