Build A Piano With JavaScript - Tutorial

Поделиться
HTML-код
  • Опубликовано: 28 янв 2025

Комментарии • 259

  • @ralphmartynsamaniego7017
    @ralphmartynsamaniego7017 5 лет назад +52

    As a developer/musician, this brought me so much joy.

  • @nicholasdejong7112
    @nicholasdejong7112 5 лет назад +24

    One of, if not the best web dev RUclipsrs I found. Keep up the good work! Your videos are beyond entertaining!

  • @Abbekej
    @Abbekej 5 лет назад +9

    When your brain has been fried, and everybody around you tells you that you're not good enough.. and you see your classmates excel above you in every way imaginable...
    Nothing, and I mean NOTHING gives me more relief than watching a smart guy, simplify a concept that has been explained to me 100 times by bad teachers. Not to mention the soft voice that gives me the feeling that everything is gonna be ok..
    Thank you, subscribed.

  • @nghianguyen-rr8on
    @nghianguyen-rr8on 5 лет назад +31

    Great, now I can learn both HTML/CSS/JS and Piano :D

  • @tristanlanner8086
    @tristanlanner8086 4 года назад +5

    You are amazing. Watching one of your videos for the first time, in less than 15 minutes I have learnt so much. Thank you so much for sharing your talent.

  • @louisham6998
    @louisham6998 5 лет назад +4

    Best HTML JS CSS tutorial I 've seen. Thank you

  • @muhamamdjamali1114
    @muhamamdjamali1114 5 лет назад +1

    Wow by just reading the title the logic just jumped into my mind man its been a long way and I've learned a lot during it.

  • @chiar995
    @chiar995 5 лет назад +1

    Even it is a weekend, watching you make me go back and start coding

  • @brecoldyls
    @brecoldyls 5 лет назад +15

    I never knew about the repeat property for key press events! That could be really useful for html5 game devving

  • @orginy
    @orginy 2 года назад

    This blows my mind, every sentence you say I learn it’s crazy🙏🏼🙏🏼thank you so much

  • @knightmarerip711
    @knightmarerip711 2 года назад

    This is a gem! Aside from learning how to build a piano, I found a lot of great techniques on how to do stuff that i have been struggling with! I have no plans of building a piano, but a lot of the coding techniques used here will definitely come in handy!!! thanx for sharing!!!

  • @gabrielsoloman5000
    @gabrielsoloman5000 5 лет назад +2

    you're awesome, bro! you are able to explain lots of stuff in a really short time, great teacher, keep on!

  • @GuRuGeorge03
    @GuRuGeorge03 3 года назад

    This is the first kinda video like this where I actually knew how to do it myself without any help. feels good

  • @maskman4821
    @maskman4821 5 лет назад +6

    This is an awesome tutorial, and I really like it !!!

  • @sauliustb
    @sauliustb 3 года назад +1

    This is such a nice tutorial. great structure, great buildup. nice speed, good linking with your other video's.
    Keep it up :D

  • @JasimGamer
    @JasimGamer 5 лет назад +4

    you can do
    function click(e){
    let aud = new Audio()
    aud.src = "notes/" +e.target.dataset.note+".mp3"
    aud.currentTime = 0
    aud.play()
    }
    and use this concept with fetch or promises

    • @harag9
      @harag9 5 лет назад

      Except that this will be slower than the way Kyle created as it has to create the audio object each time and also load in the file...

    • @JasimGamer
      @JasimGamer 5 лет назад +1

      @@harag9 with fetch and promises ? no

  • @shreyabh3047
    @shreyabh3047 3 года назад

    Thank you so much for this, you have a fan for a lifetime

  • @Lyrik-Klinge
    @Lyrik-Klinge 5 лет назад +2

    I always heard "Whisky ... Whisky ... Whisky ..." instead of "this key ... this key ... this key" :-)
    Very good programming practice!
    Good job!

  • @tolstoj9348
    @tolstoj9348 3 года назад

    You sir deserve a cookie! This was so awesome and easy to follow! I made myself a version stretching over couple of octaves. The only issue I found occurs when the horizontal viewport gets smaller past a point, the black keys become less and less centered and the white keys without a black key on their right hand side become too wide. I will figure that out now. With your awesome foundation it should be relatively straight forward. It probably has to do with the shared "--width"-CSS property for both types of keys.

  • @diegoarivera35
    @diegoarivera35 4 года назад

    man your content is soo good, thanks a lot

  • @cristoferk8314
    @cristoferk8314 3 года назад

    Thanks, Web dev Simplified! I know just HTML and CSS, and now I want to learn JavaScript! And this project is very good for beginners in JavaScript!

  • @yt.user-zull
    @yt.user-zull 5 лет назад +1

    This is the Wonder-Boy of the Web World, always does something interesting!

  • @JasimGamer
    @JasimGamer 5 лет назад +8

    rather than use js for click animation
    you can
    key:active {
    background: #ccc;
    }

    • @andy_lamax
      @andy_lamax 5 лет назад +5

      While this is entirely helpful, It wouldn't work if he used the keyboard to play the piano

    • @JasimGamer
      @JasimGamer 5 лет назад +2

      @@andy_lamax
      good note🤔

  • @debjitkarmakar5523
    @debjitkarmakar5523 5 лет назад

    Congrats on 100K Kyle 🔥🔥🔥 great fan!!!

  • @gabrielgomez6549
    @gabrielgomez6549 3 года назад

    man, your videos are amazing! thank you so much for making this content!

  • @harshithamh7930
    @harshithamh7930 4 года назад

    Superb keep doing it's gonna motivating us

  • @artgreg2296
    @artgreg2296 5 лет назад

    Really playful example for training courses to beginners

  • @tracyjackson7419
    @tracyjackson7419 2 года назад

    Thank you so much for this video! I was trying to find a way to have text play different audio files when clicked and I was able to do it thanks to your help!

  • @karimmirazul8946
    @karimmirazul8946 5 лет назад

    This is an awesome and clean video tutorial to understand how listener and basic .css works

  • @f3-faithfitnessfinance
    @f3-faithfitnessfinance 5 лет назад

    Almost 100K
    Congrats dude!

  • @srirampant3135
    @srirampant3135 4 года назад

    Thanks for sharing Bro😊

  • @vinodreddy5646
    @vinodreddy5646 5 лет назад +1

    Thanks for helping.. it means lot to us.....

  • @himbary
    @himbary 5 лет назад +9

    Lol this timing! I recently started learning piano

  • @thaanu
    @thaanu 4 года назад

    Awesome.. That actually solved a problem I had for a queue system's alert sound.. Thank you

  • @margaritabozhenova8473
    @margaritabozhenova8473 5 лет назад +5

    Best timing! I've just made an online piano and was wondering how to add audio (:

  • @maxnet9076
    @maxnet9076 5 лет назад +2

    Nice man , go to next video ) Merry Christmas Day 🎁

  • @markokoh1542
    @markokoh1542 5 лет назад +1

    Great video! Will try this out, and add web MIDI.

  • @mcny40
    @mcny40 5 лет назад +5

    Wow! I learned so many things in this single tutorial! Pretty clever coding!

  • @artemis1306
    @artemis1306 5 лет назад +4

    I subscribed coz i find it really cool and awesome 🤗

  • @배철훈-j6f
    @배철훈-j6f 2 года назад

    thank you teacher :) best tutorial

  • @NilodeRoock
    @NilodeRoock 3 года назад

    Excellent work!

  • @ky3bk449
    @ky3bk449 5 лет назад

    Лучший! Всё понятно и без воды

  • @mks33621996
    @mks33621996 3 года назад

    I love you WDS!

  • @rangabharath4253
    @rangabharath4253 5 лет назад

    Awesome as always

  • @karthicks859
    @karthicks859 5 лет назад

    Wow superb💐👌

  • @ScreenPrintR
    @ScreenPrintR Год назад

    Awesome job.

  • @armenarz4062
    @armenarz4062 5 лет назад +3

    development is fun, when requriments done by developers:)

  • @usama57926
    @usama57926 5 лет назад +1

    wow amazing tutorial

  • @TanayBhalani
    @TanayBhalani 3 года назад

    You made it amazingly simple. It's beautiful and damm minimum code, than I imagined. Thanks for sharing. I think it sums up what this channel is for, web dev simplified ✌️👍

  • @arjumandpainter9231
    @arjumandpainter9231 4 года назад +1

    Great!

  • @RitaHendrawati
    @RitaHendrawati 3 года назад

    Wow.nice .👍👍👍

  • @letscode1388
    @letscode1388 5 лет назад

    Awesome work. Thanks sir.

  • @jagsdubey9095
    @jagsdubey9095 5 лет назад

    you have very nice technique...

  • @h0ckeyd
    @h0ckeyd 5 лет назад

    Thanks for this! It's pretty awesome. Simplistic but really effective.

  • @romeobetances7964
    @romeobetances7964 5 лет назад

    Eres un genio bro, waoo, sigue así bro y no sea como los demas norteamericanos, usted es una gran persona.

  • @jimmyjiang7494
    @jimmyjiang7494 5 лет назад +2

    hi, Kyle, the key should be D Eb E F. Great tutorial. Thanks!

    • @CreeperPookie
      @CreeperPookie 4 года назад

      D#, not Eb.

    • @scottdunbar5155
      @scottdunbar5155 4 года назад

      @@CreeperPookie It's Eb, due to that tone being the tonic of a flat key, as opposed to say C# being the tonic of a sharp key. You're not really wrong, I'm just that much of a music nerd. :)

  • @drallisimo34
    @drallisimo34 4 года назад

    cool tut!!!

  • @d.learningmusician
    @d.learningmusician Год назад

    BRO, you are out here doing Lord's Work ! Many thanks from a beginner with big dreams 🔥❤🙏🙏🙏

  • @sasi_smr
    @sasi_smr 5 лет назад

    Thanks for teaching us sir 😃

  • @sidikriders3007
    @sidikriders3007 5 лет назад +4

    Thank you!! this is really good video, I never get the chance to play with audio in web app, so very new thing to me lol. One question tho, is it fine to always add event listener in every note is played without remove again the event listener? if no, where the best place to remove it?? Thanks

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +2

      This is a good point. You can pass a third parameter to the addEventListener function with an object like this { once: true } and it will only fire the event one time. This is something I should have done.

    • @kavithachellasamy2393
      @kavithachellasamy2393 3 года назад

      @@WebDevSimplified Could you please share us the usage of this object in code?

  • @saranrajg4685
    @saranrajg4685 5 лет назад

    Awesome man keep it up :)

  • @scottgonzalez7574
    @scottgonzalez7574 4 года назад

    Great video. made the piano right along side the video. one thing I'm curious about... i want to connect my midi controller to this. This vid ignited my curiosity.

  • @hugobusiness2741
    @hugobusiness2741 5 лет назад

    nice demo

  • @kirillbaryba746
    @kirillbaryba746 5 лет назад

    Maaan, cool lesson ) thanks bro

  • @JoeWong81
    @JoeWong81 5 лет назад

    Great video bro

  • @guidingtechbd
    @guidingtechbd 3 года назад

    I re-visited just for the restarting the audio! to start beginning if pressing multiple times!

  • @jaimerojas6578
    @jaimerojas6578 5 лет назад

    Very cool Thanks!

  • @freeuyghur2063
    @freeuyghur2063 5 лет назад

    Awesome. Will be beautiful if you close it by playing some songs with the piano.
    Audience will enjoy the end result of the walkthrough.

  • @chharsha231
    @chharsha231 5 лет назад

    Always Inspiring...

  • @pedllz
    @pedllz 4 года назад

    Great tutorial!...no need to do separate whiteKeys & blackKeys arrays for playing by keystrokes, just one for all 12 keys

  • @emadalhamo
    @emadalhamo 5 лет назад

    thank you pro, you are fantastic 👍

  • @usama57926
    @usama57926 5 лет назад +1

    thank u so much

  • @prabhukadode723
    @prabhukadode723 5 лет назад +1

    That's nice bro

  • @hamidalaei
    @hamidalaei 5 лет назад

    Thanks for the amazing job.
    Here is a bug I found. I think if you play that piano for a long time, it will get slow and takes a lot of memory because every time a key is pressed an ended event listener is added to the audio element, without being removed later.

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      Very true. I should have used once to prevent the event listener from firing more then one time, or removed it when the event was finished.

  • @internetuser4689
    @internetuser4689 5 лет назад +46

    WDS: creates piano
    Me: console.log

  • @avneet12284
    @avneet12284 5 лет назад

    Beyond amazing ❤️

  • @astrit
    @astrit 5 лет назад

    Great tutorial

  • @fluffydoggo
    @fluffydoggo 5 лет назад +19

    10:53 "Everything looks perfectly fine, other than the fact this piano looks ridiculous"

    • @orginy
      @orginy 2 года назад

      😭😭😂

  • @eskanderaceval
    @eskanderaceval 4 месяца назад

    I downloaded a piano pc software but I want to change the colors of the notes when I play a midi file and I can't even though I tried changing the settings 🤔

  • @musix7652
    @musix7652 5 лет назад

    Good job buddy.

  • @ARUNKUMAR-xm8kf
    @ARUNKUMAR-xm8kf 5 лет назад

    Nice job

  • @asimgiri4269
    @asimgiri4269 4 года назад

    The problem I am facing is that the audio that I have is little longer. So the ended event listener is fired only after certain seconds.
    So, I used the setTimeout() method to remove the active class after every 500ms.

  • @naveenkr5992
    @naveenkr5992 4 года назад

    Thisky thisky 🤭. Great video btw

  • @tryndamere9541
    @tryndamere9541 5 лет назад

    kyle thanks so much for the vid man :D

  • @blokche_dev
    @blokche_dev 5 лет назад +1

    I didn't know the repeat property on the keydown event. Handy!
    By the way I would have done keys with buttons instead (accessibility concerns). Thanks for sharing :)

  •  5 лет назад

    good tutorial btw key pressings are short not as long as you hold the button

  • @xMario10
    @xMario10 5 лет назад

    this guy is awesome

  • @abderrahimbouali2745
    @abderrahimbouali2745 5 лет назад +1

    one question,
    i see data-key, data-note, data-something many times in tutorials,
    are they a custom attributes or pre-defined attributes,
    how we can use them.
    Thanks 😊

  • @yeln4tsmusic
    @yeln4tsmusic 3 года назад +2

    This is an amazing tutorial, however, for some reason, despite doing exactly what you are doing, I get no sound whatsoever when I click on the keys, and I have my own audio files that are in the same directory. I also reference them in the same way you do in a subdirectory and its still not working. What am I doing wrong? I'm using notepad++ by the way, could that be part of the reason? I know that javascript is enabled in my FireFox browser so that can't be the reason.

    • @d.learningmusician
      @d.learningmusician Год назад

      same here, I even named them the same and are atm working with the files downloaded from his directory(not that it'd make any difference) any help would be much appreciated :)

  • @hegelmotokoua
    @hegelmotokoua 5 лет назад

    Super ! I like

  • @RichardBronosky
    @RichardBronosky 5 лет назад +10

    You should get an Espruino microcontroller board so you can make a REAL JavaScript keyboard.

  • @somedayiwill7361
    @somedayiwill7361 5 лет назад

    it is amazing!

  • @achyutapataki
    @achyutapataki 3 года назад

    tq for sounds

  • @MukeshKumar-co5ky
    @MukeshKumar-co5ky 4 года назад

    12:27 didn't understand the expression:- getElementById(key.dataset.note)

    • @Derek_Pixel
      @Derek_Pixel 4 года назад +1

      key.dataset.note can be simplified to element.dataset.keyname
      This means that within the specified element we are trying to find a dataset value using the specified keyname .
      So for the case of key.dataset.note if we were to play the far left white key on the piano, key.dataset.note would return C since in the html we set up the dataset data- with the keyname note and the value of C
      Now that we have the note we are playing we simply wrap key.dataset.note in getElementById() to find the audio file with the same ID as the note we are playing.
      sorry if it still isn't clear I'm new to javascript and probably not the most qualified to explain it.

  • @nehal076
    @nehal076 4 года назад

    I love him so much

  • @krishnadevz
    @krishnadevz 5 лет назад

    thank you brother keep it up next year 1M Goal right brother

  • @Jack-yi7nu
    @Jack-yi7nu 5 лет назад

    that is awesome

  • @jackfilips9048
    @jackfilips9048 5 лет назад +2

    Amazing!! Just one question, if I press on two keys in same time, it's play the two sounds together?

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      It will. You can use this piano to play chords

    • @jackfilips9048
      @jackfilips9048 5 лет назад +2

      @@WebDevSimplified I really like your tutorials! There is something special about the tutorials being short and yet clear and full of engaging content and innovations!

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад

      Thank you so much!

  • @user-bl8ed4ek7s
    @user-bl8ed4ek7s 5 лет назад +1

    Where did you find the notes mp3?

  • @rhymekidstv
    @rhymekidstv 4 года назад

    Wow... terrific video. Please mate do you have JS tutorials for beginners. I REALLY like your explanation. Many thanks