Remove `keydown` linting in rule: no-down-event-binding
See original GitHub issueno-down-event-binding rule includes keydown
event:
I understand how binding to mousedown
could cause a11y issues because it prevents a user from moving away from the target(preventing the action). However, I do not see the benefit for avoiding keydown
. Once the key is pressed a user can’t really undo it. But maybe I’m not seeing something.
It is known that keydown provides more uniform behavior across different browsers. https://www.mutuallyhuman.com/blog/keydown-is-the-only-keyboard-event-we-need/
Hello @MelSumner , I see that you contributed to this rule. What is the original reasoning behind including keydown
along with mousedown
?
Talking with our a11y team, they agree that it is fine to use keydown without compromising a11y.
Please let me know, if the community agrees, I can work on submitting a PR.
Thank you, Mario
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top GitHub Comments
@MelSumner The tab example behavior may not be desirable for all cases. For example, if we have a vertical tab component, we would want to stop the browser from scrolling the page each time the Up and Down arrow keys are pressed to activate a tab. There are similar concerns with combobox-like components, where list scrolling behavior may require programmatic control. Doing this requires adding a
keydown
event listener in order to applypreventDefault
. A better approach to limiting sequential key triggers would be to implement adebounce
. Overall, this seems to be too much of a narrow use case to broadly ban all usage ofkeydown
.Update: an example where you would want to use keyup instead of keydown: On a tabs component, you would want to configure the arrow keys that cycle between the tabs to use keyup instead of keydown- keyup responds once, whereas keydown would respond multiple times. This would be detrimental for folks with motor control issues.
I wonder if we should keep this rule as is and instead encourage folks to disable it if they really feel like they need to use it.