Use the useState() hook to create a state variable that holds the pressed state of the given key. Define two handler functions that update the state variable on key down or key up accordingly. Use the useEffect() hook and EventTarget.addEventListener() to handle the 'keydown' and 'keyup' events.
Sort: