JSFiddle - React, Tailwind, and code Playground

by JH Yap

HTML

<button id="z">Z</button>

JavaScript

document.onkeypress = function (e) { 
  e = e || window.event; 
  var charCode = e.charCode || e.keyCode, 
      character = String.fromCharCode(charCode); 
 
  if (character == 'z')
  alert(character);
};

document.getElementById('z').onclick = function (e){
    alert(document.getElementById('z').id)
}