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 :: set bg image in react 
Javascript :: json parse array local storage 
Javascript :: react native transform 
Javascript :: js check which number is larger 
Javascript :: pick random from array 
Javascript :: File is a CommonJS; it may be converted to an ES6 module 
Javascript :: reload datatable ajax 
Javascript :: js functions inside of objects 
Javascript :: angular generate directive 
Javascript :: jquery observe class change 
Javascript :: username validation formik react yup 
Javascript :: money separator in javascript 
Javascript :: javascript add element next to another 
Javascript :: javascript object first key 
Javascript :: finding in mongoose using a name 
Javascript :: get nearby store by latitude and longitude from my latitude and long node js 
Javascript :: check if object values are empty 
Javascript :: Exceeded timeout of 5000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." 
Javascript :: how to loop object javascript 
Javascript :: check if over 18 javascript 
Javascript :: javascript is valid json string 
Javascript :: drupal 8 get node from form 
Javascript :: javascript context color 
Javascript :: vuejs scrollBehavior 
Javascript :: string contains javascirpt 
Javascript :: are you sure javascript 
Javascript :: jQuert latest cdn 
Javascript :: js change button text 
Javascript :: file extension regex javascript 
Javascript :: add border to view react native 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =