(event: MouseEvent | PointerEvent)
| 24 | // where only the "virtual" click lacks a pointerType field. |
| 25 | |
| 26 | export function isVirtualClick(event: MouseEvent | PointerEvent): boolean { |
| 27 | // JAWS/NVDA with Firefox. |
| 28 | if ((event as PointerEvent).pointerType === '' && event.isTrusted) { |
| 29 | return true; |
| 30 | } |
| 31 | |
| 32 | // Android TalkBack's detail value varies depending on the event listener providing the event so we have specific logic here instead |
| 33 | // If pointerType is defined, event is from a click listener. For events from mousedown listener, detail === 0 is a sufficient check |
| 34 | // to detect TalkBack virtual clicks. |
| 35 | if (isAndroid() && (event as PointerEvent).pointerType) { |
| 36 | return event.type === 'click' && event.buttons === 1; |
| 37 | } |
| 38 | |
| 39 | return event.detail === 0 && !(event as PointerEvent).pointerType; |
| 40 | } |
| 41 | |
| 42 | export function isVirtualPointerEvent(event: PointerEvent): boolean { |
| 43 | // If the pointer size is zero, then we assume it's from a screen reader. |
no outgoing calls
no test coverage detected