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();