Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/CodeEmbed/frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ canvas {
}
${code.css || ""}
</style>
<script>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very important not to make keyboard navigation unusable on the site as a whole: (WCAG 2.1)

cc website accessibility steward @coseeian - in this case, the sketch does something on keyboard arrow up/down. I assume the proposed solution, which ignores arrow up and down, would make keyboard navigation not usable. However, if it is possible to only ignore these when there is a sketch "in focus", would that be ok?

I am actually not sure how complex it would be to only do this when a sketch is "in focus" @bryanhoffman, if the current sketch viewer component has such information

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ksen0 It should only ignore up and down arrows and the space bar when the sketch is "in focus." If I click the sketch it will start to ignore these keys, but if I then click outside of the sketch, the browser starts to "hear" up, down, and space again. I verified this locally. I think that should be suitable for accessibility concerns.

window.addEventListener("keydown", (e) => {
if (["ArrowUp", "ArrowDown", " "].includes(e.key)) e.preventDefault();
}, { passive: false });
</script>
<!-- If we need an addon script, load p5 the usual way with no caching to make sure
the import order doesn't get messed up. -->
${((code.scripts?.length ?? 0) > 0 ? [(code.scripts ?? [])] : []).map((src) => `<script type="text/javascript" src="${src}"></script>`).join('\n')}
Expand Down
Loading