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 :: js math round up 
Javascript :: nodejs command line arguments 
Javascript :: javascript disable scrolling on body 
Javascript :: copyright in javascript 
Javascript :: jquery check if input is empty on submit 
Javascript :: submit form through jquery by id 
Javascript :: npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve 
Javascript :: create element ns svg 
Javascript :: jquery datatable destroy and recreate 
Javascript :: nodejs get file size 
Javascript :: express server how to get request ip 
Javascript :: javascript reduce function to get sum of object value 
Javascript :: jsx 
Javascript :: track window resize in vue 
Javascript :: how to imporrt Browserrouter in react 
Javascript :: how to drawImage on center of canvas 
Javascript :: jquery set select readonly 
Javascript :: node js pre-commit hook bypass 
Javascript :: how prevent copy paste input react 
Javascript :: jquery clear select 2 
Javascript :: listen prop change vuejs 
Javascript :: camera helper three js 
Javascript :: js onclick open the phone application 
Javascript :: jquery get ip 
Javascript :: regex a-z javascript 
Javascript :: react style justify content space between 
Javascript :: jquery scroll into view 
Javascript :: clz32() js 
Javascript :: toggle bootstrap modal with jquery 
Javascript :: detect os javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =