| description | Use when implementing accessibility features, ARIA labels, screen reader support, accessible help dialogs, or keybinding scoping for accessibility. Covers AccessibleContentProvider, CONTEXT_ACCESSIBILITY_MODE_ENABLED, verbosity settings, and announcement patterns. |
|---|
Accessibility is a high-priority area in VS Code. Follow these patterns to ensure features work correctly with screen readers and assistive technologies.
Accessibility-specific keybindings MUST be scoped to prevent conflicts with standard shortcuts:
keybinding: { primary: KeyCode.F7, when: ContextKeyExpr.and( EditorContextKeys.focus, CONTEXT_ACCESSIBILITY_MODE_ENABLED ), weight: KeybindingWeight.WorkbenchContrib, },
Why: Without scoping, accessibility shortcuts steal commonly used keybindings (e.g., F7 for "Go to Next Symbol Highlight"). PR #293163 fixed this exact conflict.
Use AccessibleContentProvider directly — do not create custom subclasses:
getProvider(): AccessibleContentProvider { return new AccessibleContentProvider( AccessibleViewProviderId.MyFeature, { type: AccessibleViewType.Help }, () => this.getHelpContent(), () => this.onClose(), 'accessibility.verbosity.myFeature' ); }
When announcing state changes to screen readers:
- Only announce when conditions are met: Check that a search string is present, widget is visible, and screen reader is active
- Prevent double-speak: Track announcement state with a flag and use a timeout (~1 second)
- Use verbosity settings: Check
accessibility.verbosity.[feature]before verbose announcements
if (this.accessibilityService.isScreenReaderOptimized() && this.configService.getValue('accessibility.verbosity.hover') && !this._accessibilityHelpHintAnnounced) { this._accessibilityHelpHintAnnounced = true; // announce hint }
For important state changes, provide all three:
- Audio signal:
this.accessibilitySignalService.playSignal(AccessibilitySignal.chatUserActionRequired) - ARIA alert:
status(message)for screen readers - OS notification: Respect
chat.notifyWindowOnConfirmationsetting. OS notifications are conditional on window focus — only fire whentargetWindow.document.hasFocus()isfalse(seeChatWindowNotifier)
When adding a new accessible feature, register a verbosity setting:
// In accessibility configuration 'accessibility.verbosity.myFeature': { type: 'boolean', default: true, description: localize('accessibility.verbosity.myFeature', "...") }
And extend AccessibleViewProviderId and AccessibilityVerbositySettingId enums for new help providers.