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

188
Views
How To Run The Ctrl+D Shortcut On JavaScript Button Click

Is it possible to call the Ctrl+D shortcut using JavaScript button click?

I want to add a "Add To Bookmark" button on my custom context menu for my website, for that I want a function that calls the "Ctrl+D" shortcut on a button click to show the browser's default "Add to Bookmark/ Favourites" dialog box.

I have tried many pre available solutions from internet but none of them is working for me.

let bookmark = document.querySelector('.bookmark');

bookmark.addEventListener('click', ()=> {
  // Call The "Ctrl+D" Shortcut!
});
<button type="button" class="bookmark">Bookmark</button>

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

0

You can simulate keypress events using JavaScript.. but I'm not sure this will work as per your need

Give it a try

window.dispatchEvent(new KeyboardEvent('keydown', {
        key: "d",
        ctrlKey: true,
        bubbles: false,
        metaKey: false   
    })
);

For more details visit here

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!