The CloseWatcher API provides a browser-native mechanism for listening to "close requests" from the operating system. This includes Esc keypresses on desktop, the "Back" gesture on mobile, as well as some other close requests, such as those from assistive technology (notably VoiceOver on iOS).
Can a11y-dialog make use of this API to offer a better, more inclusive user experience?
I'd imagine it could be added in the same place where it is currently listening for Esc keypresses.
|
this.$el.addEventListener('keydown', this.bindKeypress, true) |
Since CloseWatcher is quite new, feature detection would need to be utilized to conditionally call the API only in supported browsers, while still continuing to call the existing bindKeypress code in older browsers.
The
CloseWatcherAPI provides a browser-native mechanism for listening to "close requests" from the operating system. This includes Esc keypresses on desktop, the "Back" gesture on mobile, as well as some other close requests, such as those from assistive technology (notably VoiceOver on iOS).Can
a11y-dialogmake use of this API to offer a better, more inclusive user experience?I'd imagine it could be added in the same place where it is currently listening for Esc keypresses.
a11y-dialog/src/a11y-dialog.ts
Line 106 in a5fe088
Since
CloseWatcheris quite new, feature detection would need to be utilized to conditionally call the API only in supported browsers, while still continuing to call the existingbindKeypresscode in older browsers.