Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

click-events-have-key-events.md 569 B

3 år sedan
12345678910111213141516171819
  1. # click-events-have-key-events
  2. 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.
  3. ## Rule details
  4. This rule takes no arguments.
  5. ### Succeed
  6. ```jsx
  7. <div onClick={() => {}} onKeyDown={this.handleKeyDown} />
  8. <div onClick={() => {}} onKeyUp={this.handleKeyUp} />
  9. <div onClick={() => {}} onKeyPress={this.handleKeyPress} />
  10. ```
  11. ### Fail
  12. ```jsx
  13. <div onClick={() => {}} />
  14. ```