Answers for "javascript check if key is pressed"

1

how to see if user clicked key in js

document.addEventListener("keyup", function(event) {
    if (event.keyCode === 13) {
        alert('Enter is pressed!');
    }
});
Posted by: Guest on April-25-2021
0

how to get which key is pressed in javascript

function myKeyPress(e){
  var keynum;

  if(window.event) { // IE                  
    keynum = e.keyCode;
  } else if(e.which){ // Netscape/Firefox/Opera                 
    keynum = e.which;
  }

  alert(String.fromCharCode(keynum));
}
Posted by: Guest on August-10-2021

Code answers related to "javascript check if key is pressed"

Code answers related to "Javascript"

Browse Popular Code Answers by Language