Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Announce characters when navigating on a line using arrow keys or deleting characters #3542

Open
pattch opened this issue Nov 3, 2021 · 4 comments
Labels
area/accessibility type/proposal A proposal that needs some discussion before proceeding

Comments

@pattch
Copy link
Contributor

pattch commented Nov 3, 2021

Details

  • Browser and browser version: All
  • OS version: All

Steps to reproduce

  1. Initialize a Terminal with screenReaderMode set to true
  2. Using a screen reader, enter some text into the Terminal
  3. Navigate to previously entered text using the left / right arrow keys
  4. Observe that although the cursor position changes, the hovered characters are not announced
  5. Compare to native Terminals, where the hovered characters are announced
@Tyriar Tyriar changed the title Announce characters when navigating on a line using arrow keys Announce characters when navigating on a line using arrow keys or deleting characters Nov 4, 2021
@Tyriar
Copy link
Member

Tyriar commented Nov 4, 2021

This is a lot more complicated that you might expect since we can't access native a11y apis. The way the announcing works in the web is by synchronizing the textarea with the prompt, but we can't reliably know what the prompt is without additional smarts. Right now the fix here will likely involve shell integration (most of which probably won't live in xterm.js) and I've been tracking it in microsoft/vscode#133084

@Tyriar Tyriar added area/accessibility type/proposal A proposal that needs some discussion before proceeding labels Nov 4, 2021
@pattch
Copy link
Contributor Author

pattch commented Nov 4, 2021

That's a good point I hadn't considered, but I do think that these a11y features are important for screen reader users.

Integrators with xterm could more easily implement these a11y features without requiring xterm to implement them directly if xterm had hooks for these events. In Google Cloud Shell, we listen to backspace inputs from the user and manually calculate the difference between the previous terminal content and the new terminal content; this is hampered a bit by having to access terminal content using the buffer.

If xterm were to expose hooks for things like this, integrators could simply announce those characters if they so choose. What I'm proposing is two interfaces added to the Terminal:

  • onCharacterDeleted: IEvent
    • just after the user enters the backspace character, if just one character is removed / overwritten, this would send off an Event with the character that was deleted
  • onCursorMove: IEvent
    • Using the existing onCursorMove, which fires an Event with type void, we simply fire an Event with the character at the position the cursor has moved to

Let me know if this sounds at all reasonable

@Tyriar
Copy link
Member

Tyriar commented Nov 4, 2021

@pattch I think you can handle that today by recording the latest keystroke via attachCustomKeyEventHandler and then handling it when the existing onCursorMove event fires, checking the buffer as needed?

FYI the plan is to look into microsoft/vscode#133084 in December I believe.

@meganrogge
Copy link
Member

This now works in VS Code microsoft/vscode#186904

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/accessibility type/proposal A proposal that needs some discussion before proceeding
Projects
None yet
Development

No branches or pull requests

3 participants