From 5d91a9362c69711d21fc3ef4495c3af99b692129 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Sat, 30 Sep 2017 11:39:55 -0300 Subject: [PATCH] Drum kit done --- 01 - JavaScript Drum Kit/index-START.html | 134 +++++++++++++--------- 1 file changed, 78 insertions(+), 56 deletions(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..8c60c8d652 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -1,66 +1,88 @@ - - - JS Drum Kit - - - + + + JS Drum Kit + + + +
+
+ A + clap +
+
+ S + hihat +
+
+ D + kick +
+
+ F + openhat +
+
+ G + boom +
+
+ H + ride +
+
+ J + snare +
+
+ K + tom +
+
+ L + tink +
+
+ + + + + + + + + -
-
- A - clap -
-
- S - hihat -
-
- D - kick -
-
- F - openhat -
-
- G - boom -
-
- H - ride -
-
- J - snare -
-
- K - tom -
-
- L - tink -
-
+ + const inactiveKey = key => { + const $div = getKeyDiv(key); + if (!$div) return; + $div.classList.remove('playing'); + } + window.addEventListener('keydown', (event) => { + playAudio(event.keyCode); + activeKey(event.keyCode); + }); - + window.addEventListener('keyup', (event) => inactiveKey(event.keyCode)); + +