score:1

Accepted answer
useEffect(() => {
  const handleKeyUp = (e) => {
    if (e.keyCode === 13) {
      setCount(prevCount => prevCount + 1);
    } 
  }

  window.document.addEventListener('keyup', handleKeyUp);

  return () => {
    window.document.removeEventListener('keyup', handleKeyUp);
  }
}, []);

Related Query

More Query from same tag