Click in order · JavaScript and React course · Module 5: useEffect and Custom Hooks
Event Listener Setup
Arrange the event listener setup:
Items to click
- window.addEventListener('keydown', handleKey);
- useEffect(() => {
- }, []);
- return () => window.removeEventListener('keydown', handleKey);
- const handleKey = (e) => { launchRocket(); };
You can check the correct answer by solving this task in the CodeWorlds game.