Here's a modal close-on-Escape that quietly does the wrong thing:
function Modal({ onClose }: { onClose: () => void }) {
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
Here's a modal close-on-Escape that quietly does the wrong thing: function Modal({ onClose }: {...
Here's a modal close-on-Escape that quietly does the wrong thing:
function Modal({ onClose }: { onClose: () => void }) {
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();

Taming DOM Events in React: useEventListener, useEventEmitter, useKeyModifier,...

The `<dialog>` element ships with focus trapping, Escape-to-close, backdrop rendering, and correct ARIA semantics — no library,…

Many developers still rely on heavy, third-party JavaScript frameworks or external UI libraries just...

Every React developer eventually meets the same fork in the road. You write an event handler that...

Custom dropdowns, tooltips, and menus built with stacked divs and click-outside listeners — the Popover API landed in every…

React useIntersectionObserver Hook: Lazy Load & Detect Visibility (2026) You want to...