Skip to content

mouse-events-have-key-events

Reports a mouseover handler with no focus handler and a mouseout handler with no blur handler on the same element.

Content that appears or changes on hover is out of reach for a keyboard user unless the same happens on focus. Pairing mouseover with focus and mouseout with blur gives both users the same behavior.

Reported
...
<app-card (click)="a()"></app-card>
<div role="heading" (keydown)="a()"></div>
@if (ok) { <div (click)="a()" aria-hidden="true"></div> }
<div (mouseover)="a()"></div>
<div (mouseout)="a()" (blur)="b()"></div>
...
<input id="a" /> <label for="a">Name</label> <label [for]="id">Name</label> <label><input /></label>
...
angular:
lint:
rules:
mouse-events-have-key-events: warn # off (default), warn, error
html:
lint:
rules:
mouse-events-have-key-events: warn # off (default), warn, error
svelte:
lint:
rules:
mouse-events-have-key-events: warn # off (default), warn, error
vue:
lint:
rules:
mouse-events-have-key-events: warn # off (default), warn, error

Enabled by the presets: html/angular-eslint-recommended.

Suppress one line with sudsy-disable-next-line mouse-events-have-key-events in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
angular-eslint mouse-events-have-key-events full