Auto change page title while bookmarking a page Here is what I'm trying:

Please review the code:

function quicklyChangePageTitle() {
  var currentTitle = document.title; // remember original title
  document.title = "temp title"; // change to the temporary title

  setTimeout(function() { // revert back to original title
    document.title = currentTitle;
  }, 1);

}
document.addEventListener("keydown", function(event) {
  if (event.ctrlKey &amp;&amp; event.keyCode == 68) { // Ctrl + D
    quicklyChangePageTitle();
  }
});
That seems like a very fragile thing to do.  If it works at all, you would still only succeed on browsers where the keyboard shortcut is ControlD.  It probably won't work on a Mac or on a mobile device.  It will probably break if the user interface is in a non-English locale with different keyboard shortcuts.  It would also have no effect if the user initiates the bookmark creation using the menu rather than a keyboard shortcut.

You should probably step back and consider why such a hack is necessary in the first place.  Ideally, you should design the page titles such that they already make reasonable bookmark titles.