In this thread I discussed a simple extension to
UIEvent to provide access to an
InputDeviceCapabilities object describing properties of the underlying input device. We shipped this API in Chrome 47 but it was really focused on solving one very specific use cases.
I’ve heard lots of other example of information developer want here, but it’s not clear to me what the key concrete use cases are, and what’s of most value to web developers? Maybe we can brainstorm here a little?
Here’s some of the main ideas I’ve heard:
When implementing custom focus rings (rather than relying on the browser’s built-in behavior), deciding whether a
focusevent is due to a device (like a keyboard) that needs focus rings. Related to (perhaps the underlying primitive explaining) this discussion.
Detecting whether a device sending ‘wheel’ events can support full 2D drag (and possibly zoom). Eg. in Google Maps, wheel events normally zoom. This makes the most sense for a physical mouse wheel. But with a high-precision touchpad that supports full 2d-panning and pinch-zoom (via ctrl-wheel events), it would be better to pan the map on most
wheelevents (like this demo page).
Detecting whether the device introduces a significant delay before firing
clickevents. Eg. libraries like FastClick try to guess if they should synthesize their own
clickfrom TouchEvents. But in many scenarios/browsers this is unnecessary.
Determining whether the device sends mouse events (eg.
mouseleavewhen hovering). For example this is true for stylus and mouse devices on Android, but not for touch screen devices.
wheelevents generated by the device precise and/or high-frequency? Eg. if the user is using a physical mouse wheel (that moves in ticks, each sending a single
wheelevent), then perhaps the page should animate positions between each event. But if
wheelevents are generated with precise delta values at a high rate, then it shouldn’t.
Determine whether an input device is implemented by currently taking up space on the screen. Eg. to tell if an on-screen keyboard is currently displayed so that the UI can be made more compact.