Go to overview: Test development & standards

Character key shortcut test page

Acknowledgement: The bookmarklet was developed for BITV-Test Prüfverbund by T-Systems Multimedia Solutions GmbH - Test and Integration Center

Bookmarklet Trigger character key shortcuts (drag to bookmarklets menu)

This is the script used on this page to add two single key shortcuts: key P (p with SHIFT key) and key p:


document.addEventListener("keydown", function(evt) {
    var key = evt.key;
    if (key === "p") {
        alert("Key p was pressed via the bookmarklet script!");
    }
    if (key === "P") {
        alert("Key P (capital P) was pressed via the bookmarklet script!");
    }
});

How to test

  1. Open DevTools in Chrome or Firefox (F12)
  2. Select DevTools tab 'Console'
  3. Make sure that the focus is not on an interactive element
  4. Run the bookmarklet 'Trigger character key shortcuts' (install by adding link above to the browser's bookmarklets)
  5. When the bookmarklet script reaches 'p' and 'P', an alert pauses the execution of the script. In real word cases, the script should now be checked to see whether any unexpected / disruptive functions are triggered.