Closed theinterned closed 1 year ago
Update (from the same conversation): looks like the role
and tabindex
attributes are dynamically added by the clipboard-copy
component, so that might be a bit tricky. You could temporarily get around it in this code by adding role="none"
and tabindex="-1"
to the actual child <button>
, plus moving aria-label="Copy to clipboard"
onto the clipboard-copy
element directly. But that's a temporary solution.
CC @sinabahram who might find this interesting.
Maybe the shortcut should be in a kbd
element?
@theinterned The kbd
element doesn't currently have any impact on screen readers. Although, even if it did, my recommendation of role="application"
would override those semantics anyway. If you want to be 100% semantically correct, you can render a kbd
element inside the input div
.
From a chat with @jscholes off-site:
This is a difficult sort of mechanism to make accessible for some users, because reliance on keyboard input (or tools that emulate it like speech recognition software) will conflict with the tool's requirement to take all keyboard input and swallow it. Indeed, as a screen reader user, it's difficult to get rid of it once loaded! :)
Here's what I'd suggest:
id="hotkey-code"
) atabindex
of"0",
so users can explicitly place focus on it.role="application"
,aria-roledescription="Input Capture"
,aria-label="Hotkey"
,aria-live="assertive"
, andaria-atomic="true"
.keydown
handler to that inputdiv#hotkey-code
, instead of the entire document.