Skip to content

Fix bug in events.js#1

Open
clairefro wants to merge 2 commits into
itscodenation:mainfrom
clairefro:main
Open

Fix bug in events.js#1
clairefro wants to merge 2 commits into
itscodenation:mainfrom
clairefro:main

Conversation

@clairefro

Copy link
Copy Markdown

Current boiler runs all the exercise code blocks on page load, giving away the point of the exercise.

Instead, commented out the code blocks be default so students can see the effect of adding event listeners

@clairefro

clairefro commented Feb 7, 2024

Copy link
Copy Markdown
Author

One more important fix - the old boiler code suggested selecting the fourth div card and adding a keydown and keyup event, however keyboard events only work on input, textarea etc elements then bubble up to the document. The event does not fire when the listener is placed on the div.

https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event

image

So instead, in the last commit, I suggested removing the part where you save the fourth card to a variable, and instead have students just add an event listener to the document in order for the event to fire properly

ex:

document.addEventListener('keydown', function() {
    // do something cool
})
``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant