Primitives / foldkit-primitives/events

InputModality

const · packages/primitives/src/events/input-modality.ts:44

Argsnone
Model{ modality: "keyboard" | "pointer" | "unknown" }
MessagesChanged { modality: "keyboard" | "pointer" | "unknown" }
Its full type
const InputModality: Bundle.Bundle<
  'InputModality',
  void,
  { readonly modality: 'keyboard' | 'pointer' | 'unknown' },
  {
    readonly _tag: 'Changed'
    readonly modality: 'keyboard' | 'pointer' | 'unknown'
  },
  never,
  never,
  never,
  void,
  {},
  {}
>

Input modality as a bundle: whether the user last drove the page by keyboard or by pointer. The browser reports the facts; the Model keeps the answer, so a view can show a focus ring only for keyboard users without reading the DOM, and a replay sees the same answer. CSS :focus-visible is the floor; this is for JavaScript that must know.

In the guides