{"record":{"id":"ee51db9882ce2cab","repo":"oxc-project/oxc","slug":"enforce-a-clickable-non-interactive-element-has-at","errorCode":null,"errorMessage":"Enforce a clickable non-interactive element has at least one keyboard event listener.","messagePattern":"Enforce a clickable non-interactive element has at least one keyboard event listener\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/jsx_a11y/click_events_have_key_events.rs","lineNumber":18,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    globals::HTML_TAG,\n    rule::Rule,\n    utils::{\n        get_element_type, has_jsx_prop, is_hidden_from_screen_reader, is_interactive_element,\n        is_presentation_role,\n    },\n};\n\nfn click_events_have_key_events_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Enforce a clickable non-interactive element has at least one keyboard event listener.\")\n        .with_help(\"Visible, non-interactive elements with click handlers must have one of `keyup`, `keydown`, or `keypress` listener.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ClickEventsHaveKeyEvents;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforce onClick is accompanied by at least one of the following: onKeyUp, onKeyDown, onKeyPress.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Coding for the keyboard is important for users with physical disabilities who cannot use a mouse, AT compatibility, and screen reader users.\n    /// This does not apply for interactive or hidden elements.\n    ///\n    /// ### Examples","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/click_events_have_key_events.rs#L1-L36","documentation":"Fires from jsx-a11y/click-events-have-key-events when a visible, non-interactive element (like a div) has an onClick handler but no keyboard event listener (onKeyDown/onKeyUp/onKeyPress). The run visitor checks non-interactive, screen-reader-visible elements with click handlers and the helper explains the keyboard-accessibility requirement.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/jsx_a11y/click_events_have_key_events.rs:18 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add an `onKeyDown` (or onKeyUp/onKeyPress) handler providing equivalent keyboard behavior","Use an interactive element such as `<button>` instead of a clickable div"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}