Last active
April 30, 2021 19:05
-
-
Save m4rk3r/8ee07b138813980553505b9aad75b402 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cities = { | |
'a': { | |
'cityName': 'Amsterdam', | |
'video': 'videos/amsterdam.mp4', | |
}, | |
'b': { | |
'cityName': 'Boston', | |
'video': 'videos/boston.mp4' | |
} | |
}; | |
let video = document.querySelector('.video-container video'); | |
let cityDisplay = document.querySelector('h1'); | |
function keyEvent(event) { | |
if (event.key in cities) { | |
let city = cities[event.key]; | |
video.src = city.video; | |
video.play(); | |
cityDisplay.innerText = city.cityName; | |
} | |
} | |
document.addEventListener('keyup', keyEvent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment