Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript key pressed enter

$('.container').on('keydown', 'input', function(e) {
  if (e.keyCode === 13) {
    e.preventDefault();
  	e.stopImmediatePropagation();
    //Do your stuff...
  }
});
Comment

javascript keyup event enter key

// Get the input field
var input = document.getElementById("myInput");

// Execute a function when the user presses a key on the keyboard
input.addEventListener("keypress", function(event) {
  // If the user presses the "Enter" key on the keyboard
  if (event.key === "Enter") {
    // Cancel the default action, if needed
    event.preventDefault();
    // Trigger the button element with a click
    document.getElementById("myBtn").click();
  }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to enable click copy function using js 
Javascript :: validation select option jquery 
Javascript :: multiple case switch javascript 
Javascript :: js html tag valu 
Javascript :: how to know which button is clicked in jquery 
Javascript :: jquery find index of this 
Javascript :: add on click to div using jquery 
Javascript :: stop a site from reloading javascript 
Javascript :: Link vs NavLink in react-router-dom 
Javascript :: generate an array of random numbers javascript 
Javascript :: alphabet to number javascript 
Javascript :: string indexing in js 
Javascript :: link href javascript 
Javascript :: run function once javascript 
Javascript :: how to find all elements starting with class jquery 
Javascript :: javascript fibonacci sequence recursion 
Javascript :: javascript new date from string dd/mm/yyyy 
Javascript :: random code generator 
Javascript :: how to get current month in express js 
Javascript :: javascript round number to 5 decimal places 
Javascript :: body-parser deprecated 
Javascript :: for in loop key 
Javascript :: for loop string array javascript 
Javascript :: node js on macbook m1 
Javascript :: usereducer react js 
Javascript :: react add class to each children 
Javascript :: how to hide ascending descending icons in datatable js 
Javascript :: multiply arrays javascript 
Javascript :: dayjs tostring 
Javascript :: how to clear node modules folder from your computer 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =