This becomes very difficult with devices such as Microsoft Surface, which come with a keyboard, mouse, and touch screen. And you can mix all 3 input modes at any time or add another input method, for example, with a stylus.
Microsoft takes the approach of abstracting input events as "pointer events." This model has been shipped to W3C . This should give you an idea of ββinput control trends.
However, I find it convenient to monitor whether touch access is available and work in accordance with the assumption that, if so, the user will use touch input for at least some time. This can lead to design decisions to eliminate those things that are completely untouchable, although this may mean compromising mouse / keyboard functions.
In your specific case, I will consider in detail the question of whether to replace input[type=number] with a user control. Most touch devices are fairly modern, and many have custom versions of standard HTML inputs.
Also be aware of accessibility scenarios that seem to support native out-of-box controls.
If you decide to implement a user control, I would advise you to detect touch functions and show your own control regardless of whether other input mechanisms are present. This means that the user control (at least) supports the touch / keyboard / mouse.
Here's my current touch test (with a disclaimer that it might break tomorrow and, of course, has not been tested on every device):
var supportsTouch = ("ontouchstart" in window) || window.navigator.msMaxTouchPoints > 0;
Tim medora
source share