Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda