Hello awesome coding experts,
Hi. After you press play, the video is being focused, and if you press any key, it’ll seem like it’s not being pressed, but that’s only because the video is the one “receiving” those key presses. If you click outside the video, then keydown function will execute normally. At least that is what happens in the code you linked to.
I think you may have to use the YouTube Player API and some “hackyness” to solve this. Using the API you can get to the
onStateChange on the player and give focus to a hidden element on the page. It will however not really work for multiple videos so you can also implement a video load function to load each of the videos on some button click.
Here is a quick example.
Thanks to both; this is helpful. I’m thinking I’ll try using onStateChange with a video playlist rather than separate videos…will ask students/teachers which is most user-friendly.