ten1seven / what-input

A global utility for tracking the current input method (mouse/pointer, keyboard or touch).
https://ten1seven.github.io/what-input
MIT License
1.36k stars 89 forks source link

Input Switches to Mouse without Movement if Cursor is in Window #40

Closed KDCinfo closed 8 years ago

KDCinfo commented 8 years ago

Hi there,

If my mouse cursor is inside the window document, and I use the keyboard, it switches the data-whatinput to "keyboard", but then within about 1 second it switches right back to "mouse". If my cursor is outside of the screen, the input stays on "keyboard".

This happens both on my site and your demo site, but not on another site I worked on in the past. Maybe something has changed since I did that site? (I only have the minified version from that site.) Or, wondering if maybe my mouse sensitivity is set higher than normal? (It's a new wireless Logitech M510 Advanced.) Could something else be triggering the listener? Or perhaps there is new code that makes the mouse movement more delicate?

I checked the doc page for settings for something like this but couldn't find anything.

Thanks.

ten1seven commented 8 years ago

Hey, @KDCinfo there is a mousemove listener at work. While input methods like touch and keyboard require an action before they can be detected, I'm using mousemove (as well as mousedown) to detect mouse usage as quickly as possible. This was added after the initial release but has been around for a little while.

This addition does get mixed reactions. What do you think about it?

KDCinfo commented 8 years ago

Thank you for the quick feedback! :)

I wouldn't mind so much if it didn't switch to 'mouse' even when the mouse isn't moved. :) I think those with limited accessibility may use both inputs from time to time, but with it switching to 'mouse' just because the cursor is inside the document window, then it seems there really is no 'keyboard' unless you move the cursor outside the window. Then again, maybe it's my own mouse's sensitivity?

I'm guessing there's not a threshold it could use to determine that the mouse has actually moved, and it's not just detecting a sensitive mouse?

If not, is there an option to disable the mousemove listener? I tried removing it in the map, but then it showed as 'undefined', so I left it alone and took my old minified version (unsure which version it is). But for me, without a mousemove threshold, the mousedown suffices.

P.S. The minified version I have was included in a Zurb Foundation 6 Sass install from earlier this year (~Feb).

Thanks again, -Keith

ten1seven commented 8 years ago

Thanks for the feedback. I've been thinking about doing a rewrite and am re-considering some of the "features" that have made their way in over the past year or so.

You might want to grab the latest version: https://github.com/ten1seven/what-input/blob/master/dist/what-input.js

Instead of commenting out the line in the map, you should be good to comment out line 260 which is where the event binding takes place for mousemove. Let me know if that doesn't work.

KDCinfo commented 8 years ago

Commenting out line 260 worked. I'll keep with this version/change. The only slight difference I see between this and my minified version is, with the minified version, it switches to 'mouse' when the cursor enters the document window. But that's really no big deal (imo).

Thank you very much for the insights. :+1: