Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. const button = document.querySelectorAll("button");
  2. const audio = document.querySelectorAll("audio");
  3.  
  4. const buttons = {
  5. '65': {
  6. audio,
  7. button
  8. },
  9. '83': {
  10. audio,
  11. button
  12. },
  13. '68': {
  14. audio,
  15. button
  16. },
  17. '70': {
  18. audio,
  19. button
  20. },
  21. '71': {
  22. audio,
  23. button
  24. },
  25. '72': {
  26. audio,
  27. button
  28. },
  29. '74': {
  30. audio,
  31. button
  32. },
  33. '75': {
  34. audio,
  35. button
  36. }
  37. }
  38.  
  39.  
  40.  
  41.  
  42. function playAudio() {
  43. Object.keys(buttons).forEach((buttonKey,i) => {
  44. buttons[buttonKey].audio[i].play();
  45. })
  46.  
  47.  
  48.  
  49. }
  50.  
  51.  
  52. addEventListener(`keydown`, playAudio );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement