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.35k stars 89 forks source link

Any way to disable session storage functionality? #99

Closed flyingL123 closed 4 years ago

flyingL123 commented 4 years ago

This may not be the intended use for your library, but part of what I was using it for was to detect whether or not there has been some interaction with the page. For example, I have some event listeners that run on the window scroll event. However, I don't want those listeners running until the user interacts with the page.

I was using an older version of what-input, and was able to rely on the fact that whatInput.ask() would return null or initial until the user actually interacted. However, after upgrading I see this is no longer the case since you are persisting the last input since a few versions ago: https://github.com/ten1seven/what-input#v510

Is there any possibility of adding an option to disable this storage functionality?

ten1seven commented 4 years ago

Hi @flyingL123, that seemed like a reasonable and useful request (and wound up adding a net of only a few lines of code -- always a plus!) so I went ahead and added this under v5.2.4 (published now). Here is the documentation for how to turn off session storage:

https://github.com/ten1seven/what-input#persisting-inputintent-across-pages

flyingL123 commented 4 years ago

Wow @ten1seven thanks so much for the quick turnaround on that!