Repository navigation
v6.0.0
A rewrite in TypeScript on modern browser APIs. The data attributes, the session storage keys, the API and the dist/what-input.js file path are unchanged, so for most sites this is a drop-in upgrade.
- Breaking: Drops support for Internet Explorer and other legacy browsers. The build targets ES2022 and is no longer transpiled.
- Breaking: Detection is built on Pointer Events only. The
mousedown,mousemove,touchstart,touchend,MSPointerDown,MSPointerMove,mousewheelandDOMMouseScrolllisteners (and the 200ms touch-versus-mouse buffer they required) are gone. - Breaking:
clearStorage()now removes only What Input's ownwhat-inputandwhat-intentkeys instead of wiping the entire session storage. - Breaking:
pointerdownnow updates the intent as well as the input, even while a form field has focus. Only keyboard use inside form fields is buffered. - Breaking:
unRegisterOnChange(fn)removesfnfrom both theinputandintentlists. - Breaking: The
InputMethodtype no longer includespointer, which was never actually reported. - Breaking: Requires Node 20+ for development. The build uses esbuild, the demo uses Vite and the tests use Vitest; Gulp, Webpack, Babel, Sass and Yarn are gone.
- Added: A
data-whathintattribute,ask('hint')and ahintevent report what the device's primary pointer suggests (mouse,touchorunknown) from thepointerinteraction media feature, before any interaction and live as devices are attached or removed. The existing attributes never use it. - Added: A
data-whatfreezeattribute opts any element (or container) into the same intent buffering that form fields get, for custom controls driven by the arrow keys (#123). - Added: An ES module build (
dist/what-input.mjs) with a properexportsmap,moduleandunpkgfields. The UMD build (dist/what-input.js) and the minified build remain for<script>tags, CommonJS and AMD. - Added:
whatInputis anEventTargetand dispatchesinputandintentevents. - Added:
whatInput.destroy()tears everything down (listeners are bound with anAbortController). - Added:
ignoreKeys()andspecificKeys()acceptKeyboardEvent.keyandKeyboardEvent.codestrings alongside legacy keycodes. The defaults are now key names. - Added: Typing inside
contenteditableelements and form-associated custom elements no longer changes the intent, just like form fields. - Fixed: Pressing a key on a checkbox or radio button switches the intent to
keyboard; they are toggled, not typed into (#128). - Fixed: Long-presses in Firefox for Android no longer flash
data-whatintent="mouse", because the emulated mouse events are no longer listened to (#94). - Added: Focus inside open shadow roots is reported for the inner element (via
composedPath()), and the active-element check follows shadow roots when deciding whether a keypress is text entry. - Added: Persisted session storage values are validated before they are used.
- Changed: Type declarations are generated from the source and shipped in
dist/. - Changed:
pointerdownandkeydownare observed in the capture phase onwindow, sowhatInput.ask()is already up to date inside any element's own event handler, even one that callspreventDefault()orstopPropagation()(#80). - Changed: When the script runs after
DOMContentLoaded(dynamicimport(), late-loaded scripts) the initial state is published immediately instead of never. - Changed: An interaction that happens before
DOMContentLoadedis no longer overwritten by the persisted value. - Fixed:
data-whatclassesseparates all classes with commas (a,b,c); previously only the first space was replaced. - Fixed:
data-whatclassesis removed when focus moves to an element without classes.
Install: npm install what-input@6 · Demo: https://ten1seven.github.io/what-input · Docs: README