Expand description
Default Action Processing for Keyboard Events
This module implements W3C-compliant default actions for keyboard events.
Default actions are built-in behaviors that occur after event dispatch,
unless event.prevent_default() was called.
§W3C Event Model
Per DOM Level 2/3 and W3C UI Events:
- Event is dispatched through capture → target → bubble phases
- Callbacks can call
event.prevent_default()to cancel default action - After dispatch, if not prevented, the default action is performed
§Keyboard Default Actions
| Key | Modifiers | Default Action |
|---|---|---|
| Tab | None | Focus next element |
| Tab | Shift | Focus previous element |
| Enter | None | Activate focused element (if activatable) |
| Space | None | Activate focused element (if activatable) |
| Escape | None | Clear focus |
§Activation Behavior (HTML5)
Per HTML5 spec, elements with “activation behavior” can be activated via Enter or Space. This generates a synthetic click event:
- Button elements
- Anchor elements with href
- Input elements (submit, button, checkbox, radio)
- Any element with a click callback
See: https://html.spec.whatwg.org/multipage/interaction.html#activation-behavior
Functions§
- create_
activation_ click_ event - Create a synthetic click event for element activation.
- default_
action_ to_ focus_ target - Convert a DefaultAction to a FocusTarget for the focus manager.
- determine_
keyboard_ default_ action - Determine the default action for a keyboard event.