Feature request: give the information about existence of mouse and/or touch devices in JS
Reported by
sylwekwa...@gmail.com,
Aug 26
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 Steps to reproduce the problem: 1. You have a website that sets up different interaction when user uses touch screen (dragging/swiping would cause scrolling), and a different one when he uses mouse (enable actions on hovering, dragging would cause moving an item, instead of scrolling etc.). 2. You want to be able to tell, whether the user has a touch screen, a mouse, or both. What is the expected behavior? Give information (i.e. in window.navigator object) about the existence and class of input devices. Even better would be information about the currently used device inside mouse event object. What went wrong? No information given. That causes inability to determine what kind of input a user has. Currently there are laptops with touch screens, iPads with big resolution etc. Browsers simulate clicks. There is no reliable way to tell what the user has. The problem exists now and will grow further in the future with increasing popularity of touch screens in laptops and trackpads in tablets. Did this work before? N/A Does this work in other browsers? No Currently no existing browser gives such information Chrome version: 68.0.3440.106 Channel: stable OS Version: 10.0 Flash Version:
,
Aug 27
Thanks for filing the issue! From comment#0, it is clear that the issue seems to be a feature request rather than a bug, hence marking it as Untriaged and requesting someone from respective team to have a look into this issue and help in further triaging it. Note: Tentatively adding component "Blink>Input", please change if this isn't apt.
,
Aug 30
I don't want to mark this as triaged yet as I didn't fully understand the use case and the experience you want to provide to the user. I assume that user might have all forms of the inputs and you should behave accordingly for each type of the input regardless of which one is connected to the computer. So if you get mouse events (or pointerevents with type mouse) you should do your behavior with respect to mouse events. The same goes for touch events. Even the compat click events coming touch events have a property showing that they are not from the mouse. So that confusion can get resolved. Repoter, can you elaborate a little more on the webpage you have in mind?
,
Aug 31
The user might use mouse, or might use touch. As far as current information provided by the browser goes, the script doesn't have any idea what the user is using or what can he use. The use case I have is a calendar with reservations. The user can reserve some days in that calendar. With mouse he can click and drag through days to have them reserved. With touch (currently detected by 'mobile' user agent) he must tap on the beginning and then on end of reservation, while swiping is used for scrolling through the calendar. The mouse event object provides in chrome "sourceCapabilities" property that tells about capabilities of the device being used, though that information would be more useful before the click event actually fired, because it has no relation to that particular event but is rather an indication of overall capabilities. As far as i know, there does not exist any property indicative of input device being used, I tested click events fired through touch and mouse and found no differences. I found out, that firefox provides 'mozInputSource' which is the property I would like, there is no similar property in Chrome. The only workaround that I know of is to attach handler to touch events and use 'preventDefault' to avoid firing mouse click events. This is a workaround, but not too nice, because it will prevent much more than just mouse events. If I would preventDefault on touch event in my calendar, I would block the scroll function. I would rather have the ability to not attach any click listener beforehand, but the script has no information to be able to do that. I would rather have that sourceCapabilities information in the window.navigator object, than in mouse event object. Then I would have the possibility to set up all my events beforehand. Once the event is fired, the capabilities information comes too late to be of any use. In the event object, I would like to have something like 'mozInputSource' from firefox.
,
Sep 6
> I would rather have that sourceCapabilities information in the window.navigator object, than in mouse event object. Then I would have the possibility to set up all my events beforehand. Once the event is fired, the capabilities information comes too late to be of any use. Regarding this point, that is not the correct assumption. Just because user has touch screen you cannot ignore all the clicks. Because they might also have mouse and then when they interact with your page with mouse you should respond to the click. Right? > As far as i know, there does not exist any property indicative of input device being used, I tested click events fired through touch and mouse and found no differences. I found out, that firefox provides 'mozInputSource' which is the property I would like, there is no similar property in Chrome. > In the event object, I would like to have something like 'mozInputSource' from firefox. I don't think this is not correct. The sourceCapabilities that you mentioned does have firesTouchEvents property and it is also populated for the click events (from mouse and from touch). Could you double check this? Does click having that property resolve the issue? Aside from all this, would pointerevents be any help? it has a property called pointerType which could be mouse/touch/pen and maybe more in the future.
,
Sep 13
Reporter feel free to continue discussion here. I'll leave this as P3 as it doesn't seem that we immediately need such an API to address a usecase that is not addressable today by the current APIs.
,
Sep 16
I was not aware of pointerevents. Now i see, this issue is pointless, I am sorry for disturbing you. |
||||
►
Sign in to add a comment |
||||
Comment 1 by susan.boorgula@chromium.org
, Aug 26