title: How to make a greasemonkey script that clicks a button on page when a key is pressed?
body: <p>I am trying to make a script for DeviantArt that clicks "Remove from notifications" when I press the delete key. Deviantart allows the user to follow artists and provides any new artwork under a common notification system. When you click some artwork from notifications there is a button on the right that lets the user remove that artwork from notifications.</p>
  
  <p><a href="https://i.imgur.com/dZ5B4Vo.png" rel="nofollow noreferrer">Image Link</a></p>
  
  <p>Here is the code I've tried which isn't working.</p>
  
  <pre><code>// ==UserScript==
  // @name           Deviations remove shortcut
  // @namespace      DeviationsRemShortcut
  // @include      http://www.deviantart.com/art/*
  // @include      https://www.deviantart.com/art/*
  // ==/UserScript==
  
  (function(){
  document.addEventListener('keydown', function(e) {
   // pressed del
    if (e.keyCode == 46 &amp;&amp; !e.shiftKey &amp;&amp; !e.ctrlKey &amp;&amp; !e.altKey &amp;&amp;     !e.metaKey) {
    document.querySelector(".remove-message-button").click(); // this will trigger the click event
    }
  }, false);
  })();
  </code></pre>
  
  <p>When I manually enter document.querySelector(".remove-message-button").click(); into the console it works as expected.</p>