Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Javascript multiple keydown at once

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #282638
    Nigan
    Participant

    Hello, so I’m learning html5 game programming and I’m now programming a game and I have an issue with simultaneous keydown
    for example I want here to move the plane with the arrows while firing with space
    I need help plz
    Thanks !

    function fire(event){
    if (event.keyCode == 32){
    bullets.push({
    bulletx:planex+90,
    bullety:canvas.height-120
    });
    }
    }

    function moveplane(event) {
    if (event.keyCode == 39) {
    if (planex > canvas.width-200){planex=planex;
    }
    else
    {
    planex=planex+planespeed;
    }
    }
    if (event.keyCode == 37) {
    if (planex canvas.width-200){planex=planex;
    // }
    // else
    // {
    // planex=planex+planespeed;
    // }
    // }
    }

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.