# Keyboard model

The kit specifies a component's keyboard behavior. A Go application can
choose its own behavior; a terminal or the cells rendition carries the
input and renders the result. The same component should behave alike in
both. The table below describes the current implementation, including
native controls whose HTML defaults are reproduced in cells. The reviewed
KeyScope API allows an application to override defaults. An entry marked
planned is not an implemented API.

Tab and Shift+Tab move among controls in document order. An open modal
keeps Tab within its controls and makes the rest of its surface inert.
The storybook confines a preview's modal to that preview, so the book's
own controls remain usable.
Escape closes a dialog when it has an `OnClose` callback. An app keeps
component values and applies the changes its callbacks report.

## Defaults by component

| Component | Keys and current behavior |
| --- | --- |
| Accordion | Planned; no kit implementation yet. |
| Alert | None of its own. |
| Alert dialog | As Dialog: Escape requests a close and Tab cycles its controls. |
| Avatar | None of its own. |
| Badge | None of its own. |
| Breadcrumb | A step with a click handler or `href` is a link: Enter or Space activates it. Other steps have no keys of their own. |
| Button | Enter or Space activates an enabled button; submit buttons also submit their form. |
| Button group | None of its own; its children have their own keys (`surfui/buttongroup`). |
| Canvas | Pressed, it has the keyboard: 0 goes home, + or = and - zoom about its centre, and the arrows pan. A KeyScope around it takes any of them first. |
| Card | None of its own; its children have their own keys. |
| Chart | None of its own. |
| Checkbox | Space toggles it; Enter submits its form when it belongs to one. |
| Collapsible | Planned; no kit implementation yet. |
| Combobox | Typing filters its options. Up, Down, Home and End move among enabled matches; Enter chooses and Escape closes. In multiple mode Backspace removes the last chip when the field is empty. |
| Command | Typing filters; Up, Down, Home and End move the highlight among enabled matches, and Enter selects. When there are no matches, navigation keys remain available to the field. |
| Command dialog | Command's keys; Escape closes the dialog and choosing an item also closes it. |
| Dialog | Escape closes; Tab and Shift+Tab cycle its controls. On close, focus returns to the opener where available. |
| Drawer | As Dialog: focus stays inside, Tab wraps, and Escape requests a close. The closing transition retains the modal until it finishes. |
| Context menu | Shift+F10 or the Menu key on an element in its area opens it under the area, its first enabled item highlighted; a context-menu gesture opens it at the pointer with none. Open, it has the keyboard and a Dropdown menu's keys; Escape, the opening keys or a choice close it and give the keyboard back. |
| Menu | The panel alone, the app's highlight: Down, Up, Home and End ask for another enabled item (OnHighlight); Enter and Space run the highlighted one. Nothing closes it: the app takes it away. |
| Dropdown menu | Enter or Space opens the trigger; Down opens at the first enabled item and Up at the last. In the open menu, Up and Down move, Home and End go to the ends, Enter or Space chooses, and Escape closes. Choosing a checkbox toggles it; choosing a radio selects it within its group. |
| Empty | None of its own. |
| Field, field set and field separator | None of their own; their controls have their own keys. |
| Form | No separate kit component; its fields and buttons determine submission. |
| Input | Text editing follows the field keymap and platform; Enter commits and submits a form when applicable. Date and time controls depend on the native control. |
| Input group | None of its own; its controls have their own keys. |
| Item and item group | An item with a click handler or `href` is a link: Enter or Space activates it. Other items and the group have no keys of their own. |
| Kbd | None; it displays a key. |
| Label | None of its own; it labels a control. |
| Native select | Up and Down choose the previous or next enabled option; Home and Page Up choose the first, End and Page Down the last. A printable character finds the next matching label. Enter and Space are taken; cells does not display a list. |
| Popover | Its trigger opens or closes it; Escape closes it and returns focus to the trigger. Children have their own keys. |
| Progress | None of its own. |
| Radio | Space selects it; Enter submits its form when it belongs to one. |
| Range / slider | Arrows step, Page Up and Page Down move ten steps, and Home and End go to the ends. Pointer taps and drags also change values. Each range thumb is a Tab stop and cannot pass the other. |
| Scrollbar | A class on a scrolling element; no component-owned keys. |
| Select | Up, Down, Home or End opens the list; when open these move its highlight among enabled items, Enter chooses, and Escape closes. In multiple mode Enter toggles the highlighted value and keeps the list open unless configured to close. |
| Sidebar | Planned; no new kit implementation yet. |
| Skeleton | None of its own. |
| Switch | Space toggles it; Enter submits its form when it belongs to one. |
| Table | None of its own; children have their own keys. |
| Tabs | Left and Right move among enabled tabs, wrapping; Home and End choose the first and last. Focus follows the selected tab. |
| Textarea | Text editing follows the field keymap and platform; Enter inserts a line break. |
| Toast / toaster | Actions and Dismiss use button activation; a leaving toast disables its buttons. There are no other toaster keys. A toast never takes the keyboard by itself: an app that walks its toasts with its own keys sets Focused, which draws the first button ringed, and runs the action itself; that doesn't close the toast as a click does, and Remove does. |
| Tooltip | No keys; Basecoat shows it on hover, not keyboard focus. Cells does not currently display it. |

Select, DropdownMenu, Tabs, Popover, Command and Dialog have Go handlers.
The same surface handlers run when a host or cells sends the event or
passes a key to the application. Cells also implements native control
editing, activation and navigation. Text fields resolve their keymap with
`hotty.Resolve`; a host and cells must agree on the platform and on the
ordered keymap. Readline-style editing (`hotty.TerminalKeys`) is
`surf.Bind(surfkey.ReadlineKeys())` on the field or on what holds it, and a
desktop's editing keys whatever the host's platform are `surfkey.CUAKeys()` or
`surfkey.CocoaKeys()` (see Editing keymaps, below).

## B1 and B2 audit

This is an audit of the merged batches, not a claim that the gaps have
been fixed:

- Button, Breadcrumb and Item use native button or link activation.
  Checkbox, Radio and Switch use native check controls. Input, Textarea
  and NativeSelect use native controls. Cells separately implements these
  controls' editing, activation, toggles and selection. Native HTML
  defaults are appropriate. Shared key vectors now exercise these controls
  against both the hottytest host and cells, including disabled controls;
  the two href-less link vectors await the hottytest fix. The vectors are
  representative, not a claim of exhaustive parity. Separate KeyScope
  vectors cover representative overrides on both renditions.
- NativeSelect has a concrete presentation difference: cells navigates its
  options with keys but does not show an open option list. The coverage
  page also records a Blitz drawing difference for its chevron.
- The first shared key vectors found that click-handler Item and
  Breadcrumb links without an `href` work in cells, but hottytest 0.8.0
  skips them on Tab even with `tabindex="0"`. Its focusability check
  returns on the link's missing `href` before checking `tabindex`. The
  framework's markup follows the approved link shape; this is reported for
  the test host rather than worked around here. The vectors also pass with
  the local hottytest fix; they remain marked until its release.
- Attrs on native wrappers can carry a `surf.Key` handler, which hears
  the keys it declares and those the control doesn't use. There is not
  yet one uniform application override for native and behavior
  components. For non-text controls cells parses the keymap separately,
  and its Tab path must match the host's: the host owns Tab outside a
  text field, while a text field's own handler can declare `tab`.
- The remaining B1/B2 components are containers or display wrappers with
  no component-owned keyboard default. Their interactive children retain
  their own behavior. Chart and Progress have no keyboard navigation.

## Declared keys

A key is declared in Go, by the code that takes it: no template carries
a key bind (the maintainer, 2026-11-18). `surf.Key(fn, keys...)` names
the keys fn takes ahead of the element:

```templ
<ul { surf.On(ctx, "rows", surf.Key(a.rowKey, "arrow_up", "arrow_down"))... }>
```

- While the keyboard is on the element or inside it, the host gives each
  declared key to the program, so fn hears it before the element uses it
  (a button's Space, a field's arrows, the surface's scroll). Without
  keys, fn hears only what reaches the program anyway.
- The surface writes each declaration as a sorted `key=program` binding.
  A focusable control's declarations go in its own `data-keys`.
  A container can offer bindings to its descendants through
  `data-keys-inner`. The `data-keys` lint rule covers both attributes in
  app sources. KeyScope markers are internal to the surface.
- A declared key fn declines goes to the enclosing handlers, then to the
  element's own use, which the surface does as the host would have: a
  button's activation, a field's edit, a check box's toggle, a select's
  pick. That is what `key=default` did in markup. A use the surface can't
  do (the host's scrolling, a date field's) is lost, and a declined `tab`
  on a field doesn't move focus.
- A field keeps printable keys from an inherited binding, and buttons
  keep Space and Enter. A focused control can intercept its native keys
  with an explicit declaration on that control.
- `escape` reaches the program anyway and isn't written; it is declared
  for OwnKeys. `tab` is a text field's own to declare (a completion), a
  fault elsewhere.
- A kit control declares its keys on the element that takes focus (K32).
  Where its handler sits on the root (Command, Combobox), the same
  handler is registered with the keys on the field too; a key the field's
  declines, the root's hears again and declines too.

`surf.Key` is for a control's own keyboard: a list's arrows, a grid, a
field's completion. Shortcuts that a menu or a palette lists are
`surfui.KeyScope`'s, below.

## Keys that aren't the program's

`surf.Key` gives keys to the program; `surf.Bind` gives them to the host,
which does one of SPEC §10.2's actions with them, and no handler hears
them. Bind's options are bindings, `surfkey.Action(action, keys...)`,
`surfkey.Unbind(keys...)` and groups (the editing keymaps `surfkey.ReadlineKeys()`,
`surfkey.CUAKeys()` and `surfkey.CocoaKeys()`, or an app's own `surfkey.Group`), and at
most one of `surfkey.Yield()` or `surfkey.Override()` for all of them.

```go
// a palette's query: readline's ctrl+w, ctrl+u, alt+b, …
surf.On(ctx, "query", surf.Input(a.setQuery),
    surf.Bind(surfkey.ReadlineKeys()))
// readline without ctrl+k
surf.Bind(surfkey.ReadlineKeys(), surfkey.Unbind("ctrl+k"))
// a pager: j and k scroll the log where the host scrolls it
surf.On(ctx, "log", surf.Bind(surfkey.Action(hotty.ScrollDown, "j"),
    surfkey.Action(hotty.ScrollUp, "k")))
// the app's leader: mod+k and the keys after it reach its keymap
surf.On(ctx, "main", surf.Bind(surfkey.Action(hotty.Prefix, "mod+k")))
// an app's own group, made once and bound wherever it's needed
var pager = surfkey.Group(surfkey.Action(hotty.ScrollDown, "j"),
    surfkey.Action(hotty.ScrollEnd, "shift+g"))
```

- **Edit actions** (`hotty.WordBackward`, …) go on a field or on what
  holds fields, as SPEC's keymap chain has it: the nearer binding wins.
  On a control that isn't a text field (a button, a select) they are a
  fault; a direct multi-line one on an `input` is too.
- **Which binding holds a key** on one element: a `surf.Key`'s or a
  KeyScope's key, the program's; then a direct Action or Unbind (two of
  one key to different actions are a fault); then the groups' bindings,
  the last read winning.
- **Then yield or override.** The program is given a key on an element
  by a `surf.Key` declaration, a prefix or a KeyScope's forwarded key. A
  binding that yields leaves such a key on an element around it alone,
  and is dropped; nothing under it on the element comes back. A page's
  `mod+k` still opens its palette from a field under ReadlineKeys, where
  ReadlineKeys would delete to the line's end with `ctrl+k`. One that
  overrides is written anyway, the nearer binding winning. A direct
  Action overrides; an Unbind and a group's bindings yield; `Yield()` or
  `Override()` sets every binding of its Bind (in a Group they are a
  fault). A key the field's own handler declares and declines is its
  binding's edit. A key declared around the field whose handler declines
  it is what the host does with the wire: under a yielding ReadlineKeys, the
  platform default's; under `Override()`, ReadlineKeys' edit.
- **Unbind** gives a key back to the host's own meaning (`key=default`):
  one of a group's keys on the element, or a key a container binds, on
  an element inside it. Taking a key back from the program says
  `Override()`. Under CUAKeys or CocoaKeys it gives the key back to that
  keymap instead (below).
- **Bindings are a render's**, as every handler is: a render that
  passes other options rebinds the element, and the host has it with
  the render's delta, an attribute change that keeps a field's caret; a
  key sequence in progress goes on.
- **A prefix** (SPEC §10.5) gives the program its key and every key
  after it, Tab and Escape too. One a Key handler takes is the surface's
  sequence: it ends once the next key has been through the handlers. One
  no handler takes is the program's leader, and the program ends it with
  `Surface.Focus`, which, with the keyboard already on the surface,
  sends `a=focus` without a target. A printable prefix still types in a
  field inside. A list's `g g` needs no prefix: a list doesn't use `g`,
  so `surf.Key(fn, "g")` hears both.
- **Scroll actions** go on what isn't a field: a key the focused element
  doesn't use scrolls the nearest element that scrolls. A field's keymap
  leaves them out, so a field under `j=scroll-down` types `j`; on a field
  itself they are a fault.
- **Cells** resolve the ancestor `data-keys-inner` maps and the focused
  element's own `data-keys`, as a host does. This includes a field's edit
  actions through `hotty.Resolve`, the scroll actions, and a prefix,
  after which the Screen gives the program every key until the
  program's `a=focus` or `a=blur`, the Screen's losing the keyboard, or a
  press that focuses an element. The protocol test host (hottytest 0.8)
  does no scroll action yet: a scroll-bound key reaches the program
  there.
- **A kit Command or Combobox** takes no handler of the app's on its
  field: it gets ReadlineKeys, CUAKeys or CocoaKeys from a `surf.Bind` on an
  element around the component.
- **Size.** The kit's own edit of a declined key on a text field
  (`hottyedit`) is linked only by what edits text: surfui's text components,
  `surfui.KeyScope` and `surf.Bind` (a pager's scroll-only Bind too). A
  plain `<input>` in an app with none of them edits nothing on a declined
  key, and that is a fault, once.

## Editing keymaps

`surfkey.ReadlineKeys()`, `surfkey.CUAKeys()` and `surfkey.CocoaKeys()` are the
editing keymaps: groups of a text field's caret and delete keys.
- **ReadlineKeys** is a terminal line's (`hotty.TerminalKeys`), over the
  host's default. Its source is GNU Readline's manual, "Bindable
  Readline Commands" in the
  [GNU Readline Library User Interface](https://tiswww.case.edu/php/chet/readline/rluserman.html).
- **CUAKeys** is IBM's Common User Access: the Windows and Linux
  desktop's keys, SPEC §10.2's where `mod` is `ctrl`. Its source is
  IBM's "Object-Oriented Interface Design: IBM Common User Access
  Guidelines", SC34-4399-00 (1992), which replaces SC34-4290, for the
  word moves (`ctrl+arrow_left`, `ctrl+arrow_right`) and the moves to
  the value's ends (`ctrl+home`, `ctrl+end`). The word deletes,
  `ctrl+backspace` and `ctrl+delete`, aren't in it: they are later
  Windows and Linux practice, as SPEC §10.2 has them. IBM no longer
  hosts it, so the link is to
  [a scan](https://archive.org/download/sc34-4399-00/).
- **CocoaKeys** is macOS's text system's, SPEC §10.2's where `mod` is
  `super`. Its source is AppKit's StandardKeyBinding.dict, in Apple's
  [Text System Defaults and Key Bindings](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html).

They layer: one Bind can hold several, read in order, a later binding
replacing an earlier one of the same key. A give-back (below) only fills
a key no group on the element binds, whatever the order.
`surf.Bind(surfkey.ReadlineKeys(), surfkey.CUAKeys())` is the desktop's keys
where they bind and readline's for the rest.

A host's `mod` says which of CUA's and Cocoa's tables a field starts
from. CUAKeys and CocoaKeys take that choice from the platform and give
it to the app, so an app can keep `super` as its `mod` and still edit
as on Linux:

```go
var keys surfkey.Option // nil: the host's own
switch cfg.Keymap {
case "cua":
    keys = surfkey.CUAKeys()
case "cocoa":
    keys = surfkey.CocoaKeys()
}
surf.On(ctx, "app", surf.Bind(keys))
// the platform's keys where they bind, readline's for the rest
surf.Bind(surfkey.ReadlineKeys(), surfkey.CUAKeys())
```

- **What changes:** each binds its own keys and gives back the other
  platform's: from a field they reach the program, as on that
  platform. Under CUAKeys on a host whose `mod` is `super`,
  `ctrl+backspace` deletes a word, and `ctrl+k` reaches the program
  instead of deleting to the line's end.
- **What stays the host's:** what `mod` stands for, so a shortcut's
  keycap; the edit shortcuts (select all, copy, paste, undo), which are
  the host's and the user's, and every key they hold, so under CocoaKeys
  where `mod` is `ctrl`, `ctrl+a` stays select all; and the host's
  scrolling. An edit-shortcut group (below) chooses the edit shortcuts
  instead: under one, CUAKeys and CocoaKeys leave out its keys, not the
  host's.
- **Where:** once, on the outermost element of each surface's view.
  Every field inside has it, the kit's included; a field outside that
  element doesn't. A field may bind the other one, or ReadlineKeys, nearer.
- **Outside a field** the give-backs reach the program too: a focused
  button no longer scrolls with the other platform's go-to-top and
  go-to-bottom keys (`super+arrow_up` and `super+arrow_down` under CUAKeys,
  `ctrl+home` and `ctrl+end` under CocoaKeys), where no group on the
  element binds them: ReadlineKeys binds `ctrl+home` and `ctrl+end`.
  `home`, `end` and the page keys still scroll.
- **Order:** on one element, where two groups bind a key, the last read
  wins. A give-back only fills: it holds a key no group on the element
  binds, before it or after it. So ReadlineKeys keeps `ctrl+k` beside
  CUAKeys in either order, and CUAKeys with CocoaKeys is both
  platforms' keys. A give-back isn't a key the program is given around
  a field either: a ReadlineKeys nearer the field still takes `ctrl+k`.
  A page's own key (a `surf.Key`) still reaches it from a field, unless
  the Bind says `Override()`.
- **Unbind under them** gives a key back to the keymap's binding, not
  to the host's platform: under CUAKeys,
  `surf.Bind(surfkey.ReadlineKeys(), surfkey.Unbind("ctrl+k"))` gives `ctrl+k` to
  the program, as on Linux, where the host's default on macOS would
  delete to the line's end.
- **On a host and in cells** a container's editing map is written once
  in `data-keys-inner`. A cells Screen's `mod` is always
  `ctrl`, so there CUAKeys changes nothing in a field and CocoaKeys is what
  makes `ctrl+k` delete.

## Edit shortcuts

`surfkey.CUAEditShortcuts()` and `surfkey.CocoaEditShortcuts()` choose a
field's edit shortcuts (select all, copy, cut, paste, undo, redo), as
the editing keymaps choose its caret and delete keys: SPEC §10.2's
where `mod` is `ctrl`, or where it is `super`, whatever the host's.

| | select all | copy | cut | paste | undo | redo |
| --- | --- | --- | --- | --- | --- | --- |
| CUAEditShortcuts | `ctrl+a` | `ctrl+c` | `ctrl+x` | `ctrl+v` | `ctrl+z` | `ctrl+shift+z`, `ctrl+y` |
| CocoaEditShortcuts | `super+a` | `super+c` | `super+x` | `super+v` | `super+z` | `super+shift+z` |

```go
// a setting: the caret keys and the edit shortcuts chosen apart,
// on the outermost element; nil is the host's own
var caret, edit surfkey.Option
switch cfg.Keymap {
case "cua":
    caret = surfkey.CUAKeys()
case "cocoa":
    caret = surfkey.CocoaKeys()
}
switch cfg.EditShortcuts {
case "cua":
    edit = surfkey.CUAEditShortcuts()
case "cocoa":
    edit = surfkey.CocoaEditShortcuts()
}
surf.On(ctx, "app", surf.Bind(surfkey.ReadlineKeys(), caret, edit))
```

- **The other platform's keys are given back:** from a field they go
  on as keys it doesn't use, to the terminal's shortcuts and then the
  program. A give-back takes a key only from an edit shortcut, so under
  CocoaEditShortcuts on a Mac host `ctrl+a` still goes to the line's
  start.
- **Fields only.** Editing actions are written once in the editing
  container's `data-keys-inner`. Fields read them, including readonly
  fields. The other platform's `program` bindings go on the affected
  fields. A document selection and a button keep the host's copy keys.
- **Only what changes is written.** CUAEditShortcuts leaves a Linux host
  using its default shortcuts alone.
- **Nothing selected:** copy and cut reach the program, as in a
  password field, so `ctrl+c` in an empty field still interrupts.
- **A separate category.** Wherever the group is in effect it decides
  the six edit actions. On its own element its keys win over
  ReadlineKeys', CUAKeys' and CocoaKeys' in either order, and its
  give-backs fill only the keys those leave. On that element and every
  element inside it, those keymaps' binding of a key to an edit action
  (ReadlineKeys' `mod+a`) gives way where the group binds the key, and
  they leave out the keys it binds instead of the host's. So CocoaKeys
  with CocoaEditShortcuts on Linux puts `ctrl+a` at the line's start,
  and a field's own ReadlineKeys under CUAEditShortcuts on a Mac gives
  `super+a` back.
- **Otherwise the nearer binding wins**, as for every binding: an
  element between the group's and the field keeps its own Action, and
  its caret and delete keys. So bind the group once, on the outermost
  element of each surface's view. Under it, Unbind gives a key back to
  the group's binding, on the fields inside.
- **A host that keeps `super`** may never send `super+c`, and a host
  that reads keys as bytes (a cells Screen, a host inside another
  terminal) never sees it. There, under CocoaEditShortcuts, the field
  has no copy key of its own; only a terminal that is the host itself
  copies the field's selection with its own copy (SPEC §11). Offer it
  as a choice, and default to the host's (no group).
- **Cells:** a Screen has no clipboard. The program copies on its own
  key (`surftui.Screen.Selection`, `surftui.Screen.Cut`), so a cells
  program makes that key follow the same setting.
- **Keycaps:** `surf.Platform(ctx).Edit` stays the host's. An app that
  shows Copy's key, in a menu, shows the key of its own setting.

## Scoped overrides

`surfui.KeyScope` gives the keys and actions of its children to bindings:
each a key, a label, a name, whether it is disabled, and the `Run` that
does it, as a menu item carries its `OnSelect`. A binding that takes a key
prevents its default. If it declines, the next enclosing scope is tried,
then the kit default. The scope nearest the keyboard goes first. Keys not
named keep their existing defaults. Each shared scope uses a distinct
enclosing element where the authored tree allows it. If nesting exhausts
the available ancestors at the document root, the surface adds a
layout-transparent boundary there. Interleaved controls use the
enclosing elements and individual controls within their scope, so
unrelated controls keep their normal keymaps and focus order. A yielding
editing map lets the scope's forwarded key win at the editing element.
Scopes apply only within their own surface.

```templ
@surfui.KeyScope([]surfui.KeyBinding{
    {Key: "arrow_down", Label: "Next log line", Name: "log.next",
        Run: a.nextLine},
    {Key: "mod+s", Label: "Save", Name: "save", Run: a.save,
        Disabled: !a.dirty},
    {Label: "About", Name: "about", Run: a.about},
}) {
    @uiselect.View(&a.choice, uiselect.Props{
        Items: a.items, Value: a.value, OnChange: a.Choose,
    })
}
```

**Where a scope reaches.** The keyboard is inside a scope while it is on:
- one of the scope's kit controls;
- an element whose `surf.On` was called inside the scope;
- or an element inside one of those.

A scope inside no other scope also has the keyboard while nothing on the
surface has it. For every focus the order is the same: the scopes around
it, nearest first, then a kit control's default, then the `surf.Key`
handlers of the focused element and its ancestors, then the program.
- A scope around one kit control writes that control's own keymap. A
  shared scope writes an inherited keymap on an enclosing element, so
  a button still activates on Space and Enter and a select keeps its
  native navigation.
- An element that types (a kit Input, Textarea or Combobox's input, a
  plain text input, textarea or editing host) keeps its printable keys,
  with or without Shift: no scope takes one from it, so a scope may bind a
  bare letter and fields still type it.
- On a plain element, a scope hears only the keys the element doesn't use
  itself, as a `surf.Key` that declares no keys does. A scope's `enter` doesn't take Enter from a
  plain button, and its `j` doesn't take a letter from a plain field.
- Static HTML with no `surf.On` on it or above it inside the scope isn't
  reached.

The keys use `surf.Key` notation, including `mod`. These are faults:
- invalid and duplicate keys;
- Tab and Shift+Tab, which stay reserved for focus traversal;
- a binding with neither key nor name;
- a binding with no `Run`.

A disabled binding's key goes on as if the scope did not name it. A
binding with no key is an action only a menu or a palette reaches. A scope
around an open dialog can intercept Escape before the dialog default.
Native and kit controls use the same scope and handler order in cells and
on a host.

## Routing

A program that decides where a key goes before the surface hears it (a
multiplexer, or cells) offers the key to the surface first when the
surface has an overlay open (Overlays), when Chars says the focused
element types it, when OwnKeys lists it, or when surfui.Bindings binds it;
otherwise the key is its own. The surface then takes it or not (Key's
taken), and an untaken key goes back to the program's keymap.

The three don't overlap: characters are Chars', the focused element's
other keys OwnKeys', and the scopes' bindings Bindings'. Tab and
Shift+Tab are the host's, in none of them. OwnKeys reads the
declarations of the focused element and of every element around it,
each key with its shift variant (the host gives that too), so a key an
app declares on its `<main>` reaches its handler through a multiplexer.
A declared character is OwnKeys' too, except on an element that types.
So are the keys an element that isn't a field binds to a scroll action
(`surf.Bind`), which the host scrolls with. A key bound to prefix is not:
a router's prefix is its own leader, and it ends the sequence with
`Surface.Focus`. Sequences inside the surface (a prefix a Key handler
takes) work where the driver offers every key to the surface first
(`surfapp`, `surftea`).

## Menus and palettes

The labels serve the user's view of the keys too:

- `surfui.Bindings(s)` lists what a surface offers now, from its last render,
  in render order, so a palette and a which-key level don't reorder as the
  focus moves. A Name is one action: listed once, and run as the binding
  of that name nearest the keyboard. A binding keeps its key only while
  the key reaches it. One a nearer scope's key shadows, whose scope the
  keyboard is outside, or which a focused plain text field takes itself
  (its keymap's edit, `surfkey.ReadlineKeys`'s `ctrl+k` among them), is listed
  without its key when it has a name (a pick still runs it), and left out
  when it has none. A `surf.Bind` is the host's action and is never one
  of them. An app's palette lists these.
- `surfui.HostMenu(s, label)` is the same list as hotty's menu (SPEC §10.7),
  for `hotty.Menu`. A host that takes menus shows its which-key level from
  it and lists the named items in its own palette. Keys come and go with
  the focus, so the menu is sent again when it changes.
- `surfui.Pick(s, name)` runs the action a pick names, as a host's menu sends
  it in a command event.

A host's open native select list can retain every key until it closes;
scopes cannot intercept those keys while that list is open. The kit's
Select draws its own list and does not have this limitation. Best-effort
fallback for intercepted text editing has known gaps: composition and IME,
undo history, clipboard, terminal edit commands, grapheme and selection
edges, rapid or stale revisions, and date and time controls. Native form
submission and complete native editing parity also need human review.
These are not gates for B3, and no protocol change is requested.
