function useKeyPressOptions(fn, options = { delay: 0 }) {
const ref = useRef({ fn, options })
ref.current = { fn, options }
useEffect(() => {
function onKeyPress() {
setTimeout(ref.fn.current, ref.options.delay)
}
window.addEventListener("keypress", onKeyPress);
return () => window.removeEventListener("keypress", onKeyPress);
}, [])
}