Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8262477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:46:24+00:00 2026-06-08T03:46:24+00:00

I am making a game with easel js and jQuery. I woud like to

  • 0

I am making a game with easel js and jQuery.
I woud like to handle multiple pressed keys at the same time.
I have this bit of code for one key:

$(document).keydown(function(e){
if (e.keyCode == 37) { 
   angle=angle+1;

}
if (e.keyCode == 40) { 
   rad=angle*Math.PI/180;
   charachter.x=charachter.x-speed*Math.cos(rad);
   charachter.y=charachter.y-speed*Math.sin(rad);

   stage.update();
}
if (e.keyCode == 39) { 
   angle=angle-1;


}
if (e.keyCode == 38) { 
   rad=angle*Math.PI/180;
   charachter.x=charachter.x+speed*Math.cos(rad);
   charachter.y=charachter.y+speed*Math.sin(rad);

   stage.update();
}

});

But how do I make it so it is rotating and moving foward at the same time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:46:25+00:00Added an answer on June 8, 2026 at 3:46 am

    Both of the events you are looking for will happen inside that listener. If you want to create an action that continues to run after the key has been pressed you need to perform that action inside a loop and activate it with your event listener. so for example ….

    $(document).keydown(function(e){
        if (e.keyCode == 40) { 
           turn = true;
        }
        if (e.keyCode == 38) { 
           move = true;
        }
    });
    
    setTimeout(function() {
        if(turn) {
           // turn
        }
        if(move) {
          // move
        }
    }, 1000 / 24);
    

    then just listen for those keys to go up in a keyup listener and set turn/move to false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a game where I have must have some objects like weapons and
I am making a game. I would like to have a joystick that moves
I'm making a game for class and for this game I have an array
I built a slideshow/decision-making game in Flash but would like to try to redo
I'm making some game, and I have made it pretty much all, but not
I am making a game, and have a Game model and a User model.
I am making a game engine using HTML5 canvas, and I have decided to
I am making a game map editor using jquery http://www.trouverunebabysitter.fr/messages/map Everything works fine on
I'm making a game with XNA. I have my camera, my background and my
I'm making a game with Corona in .lua, and i have one hell of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.