11. Building Custom React Hooks
Activity 11.1: Build a Custom Keyboard Input Hook
Solution:
Perform the following solution steps to complete this activity:
- As a first step, create a 
hooks/use-key-event.jsfile. This file will hold the custom Hook function. - Create the 
useKeyEventHook function in the newly addeduse-key-event.jsfile. Also, export theuseKeyEventfunction so that it can be used in other files (it will be used in theAppcomponent later):function useKeyEvent() { // logic to be added... } export default useKeyEvent; - Move the 
useEffect()import and call (and all the logic inside of it) from theAppcomponent body to theuseKeyEventfunction body:import { useEffect } from 'react'; function useKeyEvent() { useEffect(() => { function keyPressedHandler(event) { const pressedKey = event.key; if (!['s', 'c&apos...