Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

adding event on keypress in javascript

const elem = document.getElementById("input");

elem.addEventListener("keypress", (event)=> {
    if (event.keyCode === 13) { // key code of the keybord key
      event.preventDefault();
	 // your code to Run
    }
  });
Comment

adding event listener keypress event in javascript

let msg = document.getDocumentById('#message');

msg.addEventListener("keydown", (event) => {
    // handle keydown
});

msg.addEventListener("keypress", (event) => {
    // handle keypress
});

msg.addEventListener("keyup", (event) => {
    // handle keyup
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript loop through array backward 
Javascript :: regex do not contain 
Javascript :: Regex port number 
Javascript :: react style justify content space between 
Javascript :: js string for each char 
Javascript :: js form submit listener 
Javascript :: get input field inside div jquery 
Javascript :: how to get a random element of an array javascript 
Javascript :: Delete icon Mui 
Javascript :: javascript change web page title 
Javascript :: array contains case insensitive javascript 
Javascript :: react eslint error missing in props validation 
Javascript :: toggle bootstrap modal with jquery 
Javascript :: javascript get base url 
Javascript :: jquery reset select2 
Javascript :: check jquery version in chrome 
Javascript :: react get screen width 
Javascript :: Code to Unsubscribe all youtube channels. 
Javascript :: for char in string javascript 
Javascript :: how to get random boolean in javascript 
Javascript :: upload files in react using axios 
Javascript :: js how to convert all string in array into integer 
Javascript :: get position of element 
Javascript :: find item in object js 
Javascript :: get sibling element after element 
Javascript :: js split last occurence 
Javascript :: yup only characters regex validation react 
Javascript :: ScrollController not attached to any scroll views 
Javascript :: use emmet autocomplete with jsx vs code 
Javascript :: increment day date javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =