
Why Every JavaScript Keyboard Shortcut Library Is Broken (And What I Built Instead)
A few weeks ago, I was working on converting zxcvbn to TypeScript when I started thinking — what other JavaScript libraries haven't been properly ported to TypeScript yet? That rabbit hole led me to keyboard shortcut libraries. And what I found was shocking. Every Popular Library Uses Deprecated APIs I started auditing the most popular keyboard shortcut libraries on npm. Here's what I found: Library Weekly Downloads API Used mousetrap ~500k which (deprecated) hotkeys-js ~9M keyCode (deprecated) react-hotkeys-hook ~1.5M code (incorrect for i18n) combokeys ~200k which (deprecated) Every single one. keyCode , which , code — all deprecated or incorrect for international layouts. Why Does This Matter? The browser gives us two ways to identify which key was pressed: KeyboardEvent.code — the physical position of the key on the keyboard KeyboardEvent.key — the actual character produced by the key If you use code or keyCode , a user on a French keyboard pressing what they think is / will trigge
Continue reading on Dev.to React
Opens in a new tab


