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

144
Views
can we dispatch a KeyboardEvent of press & hold of a keyboard key?

how can i dispatch a KeyboardEvent in window of pressing a keyboard key ? in javascript ? i have scenario in which user press and hold a specific keyboard button and then drag the mouse on screen it will draw a box , but i want to press that specific button programmatically on load of document , so whenever user will clickdown and drag mouse it will draw , is this possible ?

what is have a this keydown but its not working

 window.dispatchEvent(new KeyboardEvent('keydown', {
    'key': 'control'
}));
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's a tiny bit trickier to do the "mousedown" than, for example, onlick. Here's what I'm using:

$('div').on('mousedown mouseup', function mouseState(a) {
    if (a.type == "mousedown") {
        //whatever you like
    }
});

Tell me if it helped :D

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!