Keyboard
Keyboard protocol schemas
Focus Trap Configuration Schema
Constrains keyboard focus within a specific container (e.g., modals, dialogs).
Source: packages/spec/src/ui/keyboard.zod.ts
TypeScript Usage
import { FocusManagement, FocusTrapConfig, KeyboardNavigationConfig, KeyboardShortcut } from '@objectstack/spec/ui';
import type { FocusManagement, FocusTrapConfig, KeyboardNavigationConfig, KeyboardShortcut } from '@objectstack/spec/ui';
// Validate data
const result = FocusManagement.parse(data);FocusManagement
Focus and tab navigation management
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| tabOrder | Enum<'auto' | 'manual'> | ✅ | Tab order strategy: auto (DOM order) or manual (explicit tabIndex) |
| skipLinks | boolean | ✅ | Provide skip-to-content navigation links |
| focusVisible | boolean | ✅ | Show visible focus indicators for keyboard users |
| focusTrap | Object | optional | Focus trap settings |
| arrowNavigation | boolean | ✅ | Enable arrow key navigation between focusable items |
FocusTrapConfig
Focus trap configuration for modal-like containers
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | ✅ | Enable focus trapping within this container |
| initialFocus | string | optional | CSS selector for the element to focus on activation |
| returnFocus | boolean | ✅ | Return focus to trigger element on deactivation |
| escapeDeactivates | boolean | ✅ | Allow Escape key to deactivate the focus trap |
KeyboardNavigationConfig
Keyboard navigation and shortcut configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| shortcuts | Object[] | optional | Registered keyboard shortcuts |
| focusManagement | Object | optional | Focus and tab order management |
| rovingTabindex | boolean | ✅ | Enable roving tabindex pattern for composite widgets |
| ariaLabel | string | Object | optional | Accessible label for screen readers (WAI-ARIA aria-label) |
| ariaDescribedBy | string | optional | ID of element providing additional description (WAI-ARIA aria-describedby) |
| role | string | optional | WAI-ARIA role attribute (e.g., "dialog", "navigation", "alert") |
KeyboardShortcut
Keyboard shortcut binding
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| key | string | ✅ | Key combination (e.g., "Ctrl+S", "Alt+N", "Escape") |
| action | string | ✅ | Action identifier to invoke when shortcut is triggered |
| description | string | Object | optional | Human-readable description of what the shortcut does |
| scope | Enum<'global' | 'view' | 'form' | 'modal' | 'list'> | ✅ | Scope in which this shortcut is active |