Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js key is pressed

// You can use window.addEventListener or document.addEventListener
window.addEventListener("keydown", function(event) {
    if (event.key == "key Name"){
        // Do Stuff
    }
});
Comment

js when key is pressed

document.addEventListener("keypress", function(event) {
	// do stuff
});
Comment

how to detect which key is pressed in javascript

$(this).keypress((e) => {
  if (e.key === "a") alert("you pressed a");
  else alert("you pressed " + e.key);
});
Comment

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));
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: get result and write to file node 
Javascript :: material ui align icon with text 
Javascript :: js make node with string 
Javascript :: javascript date get future 15 minutes 
Javascript :: javascript replace all occurrences of string 
Javascript :: javascript get url parameters 
Javascript :: boucle for javascript 
Javascript :: draw line in javascript 
Javascript :: history.push 
Javascript :: javascript check if object property exists 
Javascript :: fibonacci javascript 
Javascript :: time calculator js 
Javascript :: merge two objects javascript 
Javascript :: decompile electron app 
Javascript :: javascript Multiline Arrow Functions 
Javascript :: iterata a array in js 
Javascript :: react detect enter key 
Javascript :: get message author discord.js 
Javascript :: how get value of json encode in laravel 
Javascript :: js writing to json file 
Javascript :: find array with children javascript 
Javascript :: click outside javascript 
Javascript :: new File in js 
Javascript :: javascript to string big number 
Javascript :: sts get-session-token 
Javascript :: readfilesync return buffer 
Javascript :: jquey body onload 
Javascript :: html add class 
Javascript :: toaster cdn 
Javascript :: console log in vue 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =