Accessibility
Everything a pointer does here can be done without one: nodes and edges are reached with Tab and read out by name, the arrow keys move nodes, a key starts a connection or moves an edge's end, and move buttons on the selected node replace dragging with single clicks (WCAG 2.5.7).
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press _connectionKey to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press _connectionKey to move its end to another node.
bit BlowTry it
- Click the background to give the canvas focus, then press Tab: focus moves through the edges, then the nodes, each with a visible ring. A screen reader reads each one's name - "Default node two" - its state and the keys it answers to.
- Press Enter or Space to select the focused node (Shift+Enter adds it to the selection), the arrow keys to move the selection 5 units (Shift + arrows: 25), Delete to remove it and Escape to clear it.
- On a focused node, press C to start a connection from it; Tab to another node and press Enter to connect, or Escape to cancel. A screen reader hears whether Enter would connect, or why not.
- Tab to an edge and press C: its target end is picked up (C again takes the source end instead). Tab to another node and press Enter to attach it there.
- Switch Connection key to K to use that key instead, or Off to turn connecting from the keyboard off.
- Select a node: the arrow buttons above it move it 20 units per click, with no drag needed.
- Tick Connect on click, then click a handle and click another node's handle to connect them without dragging.
How it works
- Nodes and edges are in the tab order by default (
NodesFocusable,EdgesFocusable), edges first since they are drawn beneath the nodes.DisableKeyboardA11ywould take them out and turn the arrow keys off; the Keyboard Accessibility example switches each of these. - A node is announced by its
AriaLabel, else itsLabel; this page gives each node anAriaLabelthat says more than its label. Its state and keyboard instructions are read after the name, as its description. - The arrow keys move the selected nodes 5 flow units, 25 with Shift, and every move, selection and deletion is announced through the canvas's polite live region.
ConnectionKey("c") starts a keyboard connection from the focused node, or picks up an end of the focused edge to reconnect it; null turns both off. The same rules and events apply as for a drag, and the key is ignored with Ctrl, Cmd or Alt held, so Ctrl+C still copies.- The move buttons sit in a
BlowNodeToolbar, shown while the node is selected, and callMoveSelectionAsync(dx, dy): it moves the selection as an arrow key does - snapping, extents, one undo step, announced. ConnectOnClick(off) adds click-a-handle, click-another to dragging - the single-pointer way to connect.