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 :: joi custom error 
Javascript :: show hide element jquery 
Javascript :: joi object id validation 
Javascript :: forloop in js 
Javascript :: exponent in javascript 
Javascript :: datatable order number 
Javascript :: debounchow use input debounce in javascript vue.js 
Javascript :: redux devtools extension 
Javascript :: How to loop through an object in JavaScript with a for…in loop 
Javascript :: js select div 
Javascript :: jquery open page in new tab 
Javascript :: javascript check if element is visible on screen 
Javascript :: typeorm subquery 
Javascript :: react index.jsx example 
Javascript :: question mark and colon in javascript 
Javascript :: js add content to script tag 
Javascript :: axios get data 
Javascript :: node server 
Javascript :: javascript date convert to unix 
Javascript :: nestjs vscode debug 
Javascript :: javascript eval passing variable 
Javascript :: creating a 2d array in js 
Javascript :: sum all the values in an array javascript 
Javascript :: math.floor js 
Javascript :: deleteOne 
Javascript :: how to show 1 to 10 odd numbers in javascript 
Javascript :: node js sqlite3 
Javascript :: how to change package name in ios react native 
Javascript :: key value json javascript 
Javascript :: javascript declare a variable 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =