Where key events arrive. In a browser this is window;
tests pass a fake, which is what makes the focus-loss behaviour above
testable without a DOM.
Every held code, as a live read-only view.
Live rather than a copy so a per-frame read allocates nothing (§7b); frozen so a caller cannot edit the set this class maintains.
Tracks which physical keys are currently held on a KeySurface.
Construction registers listeners; KeyboardState.dispose removes them. A caller that never disposes leaks two listeners and keeps the surface alive, which is why
disposeis idempotent and safe to call from a teardown path that may run twice.