1

I want to add a bookmark when link is clicked in chrome. How can I trigger a ctrl+d keys with jQuery?

 $('.bookMark').click(function(){
  var e = jQuery.Event( "keydown", { keyCode: 116 } );
  jQuery("body").trigger( e );
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="#" class="bookMark">add bookmark</a>
Shiladitya
  • 12,003
  • 15
  • 25
  • 38
sem
  • 61
  • 5
  • 3
    Possible duplicate of [Definitive way to trigger keypress events with jQuery](https://stackoverflow.com/questions/832059/definitive-way-to-trigger-keypress-events-with-jquery) – Carsten Løvbo Andersen Apr 08 '19 at 08:38
  • 1
    You might want to look at [this](https://stackoverflow.com/questions/10033215/how-do-i-add-an-add-to-favorites-button-or-link-on-my-website).. rather than trying to trigger keys. – Adrian Apr 08 '19 at 08:38
  • Possible duplicate of [How do I add an "Add to Favorites" button or link on my website?](https://stackoverflow.com/questions/10033215/how-do-i-add-an-add-to-favorites-button-or-link-on-my-website) – freedomn-m Apr 08 '19 at 08:40

1 Answers1

0

I think jQuery Hotkeys Plugin is the most easiest plugin for this

[https://github.com/jeresig/jquery.hotkeys][1]

  • Hotkeys Plugin catches what key you click , I need ctrl+d event triggers when link clicked – sem Apr 08 '19 at 09:02