Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: javascript
keyboardaccessibilityreadabilityevents
Compare keyboard events by named keys, not codes
Use event.key with readable names (ArrowUp, Enter) rather than numeric keyCodes/indices for clearer keyboard handling.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | if (e.keyCode === 38 || e.keyCode === 40 || e.keyCode === 13) {} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Enter') {} |
Explanation (EN)
Objašnjenje (HR)