JSFiddle - React, Tailwind, and code Playground

by tobek

HTML

Click here, then try command+s, then command+n

JavaScript

document.onkeydown = function(e){
  if (e.metaKey && e.keyCode == 'N'.charCodeAt(0)){
    e.preventDefault();
    alert("capture command+n");
  }
  else if (e.metaKey && e.keyCode == 'S'.charCodeAt(0)){
    e.preventDefault();
    alert("captured command+s");
  }
}