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

175
Views
KeyIsDown does not seem to work with the right arrow

I'm writing a simple 2D platformer game on p5js, with Visual Studio Code 2022. I want to move this dinosaur sprite to the right and the left, however the keyIsDown for the right arrow doesn't work. I get no error message, and the game is always functional, and the key on the keyboard is working, but the sprite doesn't move to the right. Any ideas on how to solve this?

the code I wrote: code image

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Two answers:

  1. You could use the function keyIsPressed(LEFT_ARROW)

  2. You could have a separate function keyIsDown() outside of the draw function.

function keyIsDown(){

  if(key == LEFT_ARROW){

    doTheDinoStuff();
    
  }
}
about 4 years ago · Juan Pablo Isaza Report
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!