Skip to main content

a11y/useKeyWithClickEvents

MISSING DOCUMENTATION

Examples

Invalid

<div onClick={() => {}} />

 file.tsx:1 lint/a11y/useKeyWithClickEvents ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Pair the onClick mouse event with the onKeyUp, the onKeyDown, or the 
    onKeyPress keyboard event.

    <div onClick={() => {}} />
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

  Actions triggered using mouse events should have corresponding
    keyboard events to account for keyboard-only navigation.

<div onclick="() => {}"></div>

 file.html:1 lint/a11y/useKeyWithClickEvents ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Pair the onClick mouse event with the onKeyUp, the onKeyDown, or the 
    onKeyPress keyboard event.

    <div onclick="() => {}"></div>
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  Actions triggered using mouse events should have corresponding
    keyboard events to account for keyboard-only navigation.

Valid

<div onClick={() => {}} onKeyDown={this.handleKeyDown} />
<div onClick={() => {}} onKeyUp={this.handleKeyUp} />
<div onClick={() => {}} onKeyPress={this.handleKeyPress} />
<Button onClick={() => {}} />
<div onclick="() => {}" onkeydown="() => {}" ></div>
<div onclick="() => {}" onkeyup="() => {}" ></div>
<div onclick="() => {}" onkeyup="() => {}" ></div>