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

241
Views
Can I assign keys to the my calculator in JavaScript?

I'm new to coding and to JavaScript, and I wanted to code a calculator as a task. Everything worked well until now: My question is: Can I use keys to use my calculator? So, e.g. if I want type the number 5 into my calculator, I have to press on the button I created with my mouse. How can I assign keys to them?

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

0

You can use the keydown event. For example, the following code should solve your problem. It listens for when the 5 key goes down and has a comment where you should call whatever function you need to use.

document.addEventListener("keydown", e => {
    if(e.code == "Digit5"){
       // Add the number 5 to your calculator
    }
});
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!