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 4237026
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:43:10+00:00 2026-05-21T02:43:10+00:00

I know its possible but I cant seem to figure it out. In its

  • 0

I know its possible but I cant seem to figure it out. In its basic form I have a canvas circle moving 5 pixels every key event however this seems to be rather slow at firing and really jumpy, plus it stalls when changing key or changing from rapid key press to holding down.

So can someone enlighten me of a way ofwhich this could work without it stuttering?

Thanks.

  • 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-05-21T02:43:10+00:00Added an answer on May 21, 2026 at 2:43 am

    What you want to do is set variables on keydown and keyup to true or false that you check every tick. Something like this:

    var tickRate = 30,
        keyDown = {},
        keyMap = {
            37: 'left',
            38: 'up',
            39: 'right',
            40: 'down'
        };
    
    $('body').keydown(function(e){ keyDown[keyMap[e.which]] = true;  });
    $('body').keyup(function(e){   keyDown[keyMap[e.which]] = false; });
    
    var tick = function() {
      if        (keyDown['up']) {
        // up code
      } else if (keyDown['down']) {
        // down code
      } else if (keyDown['left']) {
        // left code
      } else if (keyDown['right']) {
        // right code
      }
    
      // other code
    
      setTimeout(tick, tickRate);
    };
    
    tick();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know it's possible, but I can't seem to figure it out. I have
Excuse the poor phrasing, I know it's possible but I can't figure out what
I know this is probably simple, but I can't seem to figure out if
I know its possible to receive a dayClick event on Fullcalendar. But I would
I don't know if its possible or not, but here's what I need. I'm
I don't know if it's actually possible to do, but I have a text
I've done this before, so I know it's possible, but I can't seem to
This should be really simple, but I can't seem to figure out what to
I know it's possible to use DependencyResolver and register Castle Windsor with MVC but
I know it's possible with jQuery, but I'm having some serious troubles with this

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.