title: Event listener for multiple keys in React?
body: <p>I would like to have an event listener to detect when command+c is pressed so that I can copy something to the clipboard. How do I listen for multiple keys? I have tried something using <code>useState</code>, <code>useEffect</code>, and <code>document.addEventListener</code>, but it didn't work. Here is my code:</p>
  <pre><code>const [metaPressed, setMetaPressed] = useState(false)
  
    useEffect(() =&gt; {
      document.addEventListener('keydown', (e) =&gt; {
        
        if (e.key === 'Meta') setMetaPressed(true)
          
      })
    })
  
    useEffect(() =&gt; {
      document.addEventListener('keyup', (e) =&gt; {
  
        if (e.key === 'Meta') setMetaPressed(false)
        
      })
    })
  </code></pre>