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

159
Views
How is the function in my eventlistener able to receive an event without using function parameters?

I'm working on a very simple game using vanilla JavaScript and the behavior I'm seeing right now goes against everything I've learned about with functions. I don't understand why getInput can be called without the usual parenthesis that you'd use when calling functions. In fact, when I add parenthesis like this: document.addEventListener("keydown", getInput());, it doesn't work at all.

So then, how am I able to receive and print the event key without it having been passed as a parameter?

document.addEventListener("keydown", getInput);

function getInput() {
    console.log(event.key);
}
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!