SCR35: The onclick Event Trick That Actually Works for Keyboards
Marcus · AI Research Engine
Analytical lens: Operational Capacity
Digital accessibility, WCAG, web development
AI-assisted · Source-linked · Editorially reviewed · Methodology
Trust note
This article was drafted with AI assistance, reviewed against accessibility.chat editorial standards, and should be treated as research and education rather than legal advice. We prioritize primary sources and correct material errors.

What does it actually take to make a JavaScript action keyboard accessible? WCAG Technique SCR35 answers this with a deceptively simple insight: stop inventing custom event handlers and use the ones browsers already provide.
The technique is elegant. Attach your scripting function to a natively actionable HTML element — a link or a button — and the onclick event becomes device-independent automatically. Mouse click, Enter key, Space bar, accessibility API trigger: all of them fire the same handler. No custom keydown listeners. No role="button" gymnastics on a <div>. Just the platform doing what it was designed to do.
The Technique
SCR35 (opens in new window) is an official W3C technique for meeting WCAG 2.1.1 Keyboard (opens in new window), used in combination with G90: Providing keyboard-triggered event handlers. Its scope is narrow and its implementation is fast — which makes it one of the highest-ROI techniques in the catalog.
The core pattern, directly from the W3C source:
<script> function doStuff() { // do stuff return false; }</script><a href="#" onclick="return doStuff();">do stuff</a>A few things to notice here. First, the href attribute is required — without it, the <a> element isn't a true link and won't receive keyboard focus or fire events correctly. Second, return false prevents the browser from navigating to the href target after the script runs. Third, onclick sounds mouse-specific but isn't: the browser maps it to the element's default action, which fires on Enter (for links), Space or Enter (for buttons), and through the accessibility API.
The W3C document also defines a more robust variant — a link that degrades gracefully when JavaScript isn't available:
<a href="dostuff.html" onclick="return doStuff();">do stuff</a>Here, dostuff.html provides the same functionality server-side. If scripting is unavailable, the user navigates to a page that does the work. This is the pattern teams should default to when building accessible, progressively enhanced interfaces.
For button-based interactions:
<input type="button" value="Do Stuff" onclick="doStuff();" />Buttons don't require return false to prevent navigation — they have no default navigation behavior. And unlike anchor elements, buttons are semantically correct for actions that don't navigate anywhere. The choice between <a> and <button> should follow semantic intent: navigation → link, action → button.
Why This Matters
The failure mode SCR35 prevents is common and costly. Development teams frequently attach onclick handlers to non-interactive elements — <div>, <span>, <li> — because they want click behavior without the default styling of a link or button. The result looks fine with a mouse. With a keyboard, it's invisible. The element never receives focus. The action is unreachable.
Screen reader users hit this constantly. A sighted mouse user clicks a custom dropdown trigger styled as a <div>. A keyboard user tabs through the page and the trigger simply doesn't exist in the focus order. A screen reader user navigating by interactive elements finds nothing. The feature is functionally absent for a significant portion of the population.
Switch access users face the same wall. Voice control users can't target elements that aren't in the accessibility tree as interactive controls. The impact cascades across disability types — not just one community, but many.
This is precisely why WCAG 2.1.1 Keyboard (opens in new window) exists as a Level A requirement. It's foundational. Everything else in keyboard accessibility builds on the assumption that interactive controls are actually reachable.
How It Works
The mechanism behind SCR35 is the browser's event model. Native HTML elements carry implicit semantics that the browser translates into accessibility API properties. A <button> has a role of button, is focusable by default, and fires its onclick handler when the user presses Space or Enter. An <a href> has a role of link, is focusable by default, and fires its onclick handler on Enter.
This is device independence in practice. The developer writes one handler. The browser handles the input modality. No additional code required.
Contrast this with the <div onclick> pattern:
<!-- This breaks keyboard access --><div onclick="doStuff();">Do Stuff</div>To make this equivalent to a button, a team would need to add tabindex="0", role="button", a keydown handler listening for Enter and Space, and visual focus styles. That's four additional implementation steps — each one a potential failure point. SCR35 replaces all of them with a single correct element choice.
Applying This
In code review: Flag any onclick handler attached to a non-interactive element. This is a near-certain WCAG 2.1.1 failure. The fix is almost always a one-line change — swap the element type.
In automated testing: Tools like axe-core (opens in new window) and Lighthouse detect some instances of click handlers on non-focusable elements. But as our research on testing methodology shows, automated tools catch at most 37% of accessibility issues — manual keyboard testing is essential here. Tab through every interactive component and verify that keyboard focus reaches it and activates it correctly.
In design systems: The highest-leverage intervention is upstream. If your design system's component library uses native <button> and <a> elements as the foundation for interactive controls, SCR35 compliance becomes the default — not a remediation task. Teams building on <div>-based custom components will keep producing this failure at scale.
Quick win: Audit your JavaScript codebase for addEventListener('click', ...) or inline onclick attributes attached to elements that aren't <a>, <button>, <input>, or <select>. Each hit is a candidate for SCR35 remediation.
One important note on href="#": The W3C document acknowledges this is a no-fallback pattern that should only be used when scripting is confirmed as an accessibility-supported technology in your deployment context. The progressive enhancement variant — with a real href pointing to a server-side equivalent — is more robust and should be the default where feasible.
On language access: SCR35 compliance ensures keyboard users can activate a control. But if the control's label is only in English, a keyboard-accessible button is still inaccessible to users who read Vietnamese or Spanish. Tools like idioma.chat (opens in new window) address this by translating not just visible text but the full accessibility layer — ARIA labels, button text, form validation messages, and dynamically loaded content. Keyboard accessibility and language accessibility are both access barriers, and solving one without the other leaves real users behind.
CORS Perspective
From an operational capacity standpoint, SCR35 is one of the cleanest fixes in the WCAG catalog. The implementation cost is low — often a single element substitution — but the impact on keyboard and screen reader users is immediate and significant. For teams managing a backlog of accessibility debt, this belongs on the "chop list": high impact, low skill requirement, fast execution. The risk dimension is also clear: onclick on non-focusable elements is a Level A failure, meaning it represents baseline non-compliance that exposes organizations to legal challenge under Title III of the ADA (opens in new window). Teams that embed SCR35 patterns into their design system linting rules and component libraries convert a recurring remediation cost into a one-time architectural fix — which is exactly the kind of sustainable, scalable accessibility investment that moves organizations up the maturity curve.
About the Marcus lens
An operational lens on digital accessibility. Frames findings around what implementation and maintenance actually require — WCAG conformance, engineering effort, and day-to-day web development practice.
Marcus is an AI analyst lens, not a human staff member. It helps frame this article through a consistent accessibility perspective.
Specialization: Digital accessibility, WCAG, web development
View all articles using this lens →Primary source reviewed: https://www.w3.org/WAI/WCAG22/Techniques/client-side-script/SCR35 (opens in new window)
Transparency Disclosure
This article was drafted with AI assistance and reviewed against our editorial methodology. We disclose that process so readers can judge the work clearly.