Keydown() works erratic if you have 2 keyboards!


#1

So, I got seriously stuck on the exercise which uses keydown as the event that moves your div 10 pixels to the right.

I did it exactly as it's hinted, but it did not work. I have fixed it, so my point of sharing it here is to help others who experience a similar issue.

I double-and triple-checked my code, it looked perfect. So, in order to identify what was wrong, I started changing things.

First I replaced keydown for hover as an event, and it worked. So the animation was not the problem. It must be the keydown().

After much head scratching because honestly there's not much to change in that single line of code, I thought, maybe it's someting with my physical keyboard.

And yes, that was the issue. I use a docking station with my laptop, so "I have two keyboards". It turns out the keyboard event which could be picked up was the one generated by the laptop keyboard, whereas I was using the USB keyboard.

Solution... quite simple. Just try tapping on ALL keyboards to generate your events and pass the test for the lesson.

https://www.codecademy.com/courses/web-beginner-en-JwhI1/1/4?curriculum_id=50a3fad8c7a770b5fd0007a1#


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.