Learn JavaScript KEY EVENTS in 10+ minutes! ⌨

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • // eventListener = Listen for specific events to create interactive web pages
    // events: keydown, keyup
    // document.addEventListener(event, callback);

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

  • @BroCodez
    @BroCodez  9 месяцев назад +10

    FYI I was pretty sick while filming so my voice sounds kind of weird.
    // eventListener = Listen for specific events to create interactive web pages
    // events: keydown, keyup
    // document.addEventListener(event, callback);
    const myBox = document.getElementById("myBox");
    const moveAmount = 10;
    let x = 0;
    let y = 0;
    document.addEventListener("keydown", event => {
    myBox.textContent = "😲";
    myBox.style.backgroundColor = "tomato";
    });
    document.addEventListener("keyup", event => {
    myBox.textContent = "😀";
    myBox.style.backgroundColor = "lightblue";
    });
    document.addEventListener("keydown", event => {
    if(event.key.startsWith("Arrow")){
    event.preventDefault();
    switch(event.key){
    case "ArrowUp":
    y -= moveAmount;
    break;
    case "ArrowDown":
    y += moveAmount;
    break;
    case "ArrowLeft":
    x -= moveAmount;
    break;
    case "ArrowRight":
    x += moveAmount;
    break;
    }
    myBox.style.top = `${y}px`;
    myBox.style.left = `${x}px`;
    }
    });

    • @Vio.444
      @Vio.444 9 месяцев назад

      👽👽👽👽👽👽👽👽

    • @jakubmatusz1542
      @jakubmatusz1542 9 месяцев назад

      Could you paste HTML and CSS code also? :)

    • @iam_mausam
      @iam_mausam 7 месяцев назад

      @@jakubmatusz1542


      Document

      body{
      margin: 0;
      }
      #myBox{
      background-color: lightblue;
      width: 200px;
      height: 200px;
      font-size: 7.5rem;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      }

      🐶

    • @-_SleepAndEat_-
      @-_SleepAndEat_- 5 месяцев назад

      Bro can you do Kali Linux ?

    • @joachimuche424
      @joachimuche424 3 месяца назад

      😂thx

  • @doronfeldman5152
    @doronfeldman5152 9 месяцев назад +13

    You are the best programming channel. Only a month and a half ago I started learning on your channel and I have already made a site that checks answers and has 8 pages

  • @Pawfessor1
    @Pawfessor1 2 месяца назад +1

    how do i control arrow keys on mobile? 😂

  • @Marsjemijntje
    @Marsjemijntje 9 месяцев назад +3

    Oh my days, I was just wondering about some code for simple movement cause I am think of making a game.... and here you are!
    Thank you for all your videos they are super helpful and you always keep it fun!🍬

    • @NihaltheGreat
      @NihaltheGreat 9 месяцев назад

      who the f makes a game with html

    • @Marsjemijntje
      @Marsjemijntje 9 месяцев назад

      @@NihaltheGreat Are you okay? For everyone's sake, I will leave it at that.....😘

    • @NihaltheGreat
      @NihaltheGreat 9 месяцев назад

      @@Marsjemijntjei didn't know about html game devlopment, sorry, i always did it with razium(c++) libary

    • @l-fitness3590
      @l-fitness3590 8 месяцев назад +1

      @@NihaltheGreatanyone like me whose new to coding

  • @widespectrumcreators4691
    @widespectrumcreators4691 8 месяцев назад +1

    Bro code= great tutorials with EPIC voice 😀😀😛👍👍🤩🤩

  • @jayac4400
    @jayac4400 7 месяцев назад +1

    Excellent teacher 😊 thank you for explaining very easily to understand

  • @programmated_brian
    @programmated_brian 9 месяцев назад +1

    best tutorials in a shorter amount of time, keep doing these man. expecting a playlist on new -v

  • @thaitrongson2249
    @thaitrongson2249 9 месяцев назад +2

    Thank you

  • @QaisZayed.work90
    @QaisZayed.work90 5 месяцев назад +1

    Thank you !

  • @tatsu8001
    @tatsu8001 26 дней назад

    bro's explanation is so sigma

  • @therealpunit
    @therealpunit Месяц назад

    Just Came to learn keyboard Events but learned something more extraordinary alongwith that.

  • @MEIYANG-sj2sb
    @MEIYANG-sj2sb 4 месяца назад

    thank you! you explained clearly and the example you showed was fun and relevant to the learning object

  • @RajveerSinghnegi-y9l
    @RajveerSinghnegi-y9l 24 дня назад

    love it 😍

  • @snub7577
    @snub7577 9 месяцев назад +4

    you are a legend man

  • @joachimuche424
    @joachimuche424 3 месяца назад

    Danke wirklich vielen Dank

  • @nihongo_
    @nihongo_ 6 месяцев назад

    WW

  • @jiyoungkim9258
    @jiyoungkim9258 9 месяцев назад

    love watching this series