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

Why is 'form' mentioned specifically when this lib deals with any interactive element, regardless it's part of a form or not. #100

Closed brightpixels closed 4 years ago

brightpixels commented 4 years ago

Hello, Not sure if I am missing something but why is 'form' mentioned specifically when this library is a solution for any interactive element, regardless it's part of a form or not.

ten1seven commented 4 years ago

Hi @brightpixels,

Forms fields are the one location where mouse users will predictably have to use their keyboard. Since one major usage of What Input is for styling focus states, I wanted to provide a way to allow developers a way to specify different styling for primary mouse users versus keyboard users. Like in my demo, mouse focus states are subtle blue, while keyboard focus states are bold orange.

Since this may not be how you want to handle things, I provided two indicators: data-whatinput tells you what the input method is instantly in every context. data-whatintent "smooths" out the interactions and persists the mouse state even if someone starts typing in a form field.