Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

85
Views
onKeyPress causing moveTo to not move an object permanently

I'm trying to make a game in kaboomjs right now and I'm on the starting menu and I've come across a problem where the object that indicates which button is selected is going right back to its original position when using the onKeyPress or onKeyDown functions. Whenever I use moveTo outside of the onKeyPress or onKeyDown blocks it'll stay at the position, but it seems to just go to the new position for a split second when I use onKeyPress or onKeyDown to detect if the down arrow is being pressed. Anybody know why this is or should I open an issue on the kaboomjs github page?

let selected = startButton;

const selArrow = add([
  sprite("selArrow"),
  pos(selected),
  "ui",
  scale(1.5),
  origin("center"),
]);

onKeyPress("down", () => {
  if (selected == startButton) {
    selected = optionsButton;
    selArrow.moveTo(selected.pos.x-10,selected.pos.y+5);
  } else {
    selected = startButton;
    selArrow.moveTo(selected.pos.x-10,selected.pos.y+5);
  }
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!