sigil88
1/22/2017 - 4:32 PM

Event listener example, vanilla JS

Event listener example, vanilla JS

window.addEventListener('keydown', function(e) {
  // uses ES6 templating
	const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
	console.log(audio);
});
window.addEventListener('keydown', function(e) {
	// lookit all the things!
	console.log(e); 
	const key = e.keyCode;
	console.log('keyboard code is ' + key);
});