←back to thread

293 points ulrischa | 1 comments | | HN request time: 0.211s | source
Show context
marcellus23 ◴[] No.42174016[source]
> All we had to do was change the isInvokedByMouse to check that screenX and screenY don't equal 0, rather than checking if they are greater than 0.

It's obviously extremely unlikely but what if the mouse is actually at 0,0 when the user clicks? I'm not very familiar with JS, is checking for != 0 really the best/only way to do this?

EDIT: actually upon going back, I realized I didn't fully process this sentence originally but it seems to address this:

> We should probably do further refactoring of the event handler function, since it's complicated by the fact that it also handles keydown events. For now, though, this fix will do just fine.

replies(3): >>42174129 #>>42174225 #>>42174311 #
1. tomjen3 ◴[] No.42174311[source]
No its not. You can do media select on if the primary input device is a pointer device (and, further, if it has high accuracy) and then filter on that.

I used it to select which layout to show in the past.

If you want to listen to input on touch only then you can do that and call preventDefault on the event so that the browser does not then cause a click event. Or you can just save yourself the trouble and write a click handler.