Keyboard

:= []

Global (document-level) keyboard subscriptions. Each firing carries the KeyEvent record: the key ("a", "Enter", "Escape", ...), the physical code ("KeyA", ...), the modifier flags, and whether it is a held-key auto-repeat. Return one of these from subscriptions for as long as it should listen; dropping it from the list removes the document listener.

The key filter and preventDefault decisions are data on the subscription rather than logic in your app: the browser handler applies them without entering the app, and together with the event name they form the subscription's identity for diffing. An empty filter matches every key, and the prevent-default variant suppresses the browser default for exactly the filtered keys.

Keys compare against the event's key string exactly, so the match is case-sensitive: Shift makes "a" arrive as "A". List both to catch either.

For keyboard events on a specific element, see Attribute.on_keydown.

on_down : (KeyEvent -> msg) -> Sub(msg)

Msg for every keydown.

on_up : (KeyEvent -> msg) -> Sub(msg)

Msg for every keyup.