jquery (or pure js) simulate enter key pressed for testing
Demo Here
var e = jQuery.Event("keypress");
e.which = 13; //choose the one you want
e.keyCode = 13;
$("#theInputToTest").trigger(e);
How to press the enter-key inside an input field with pure JavaScript or jQuery?
Use Keyup Event Listener. keycode for enter is 13.
For More Example, Please visit https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_trigger_button_enter
let plzField = document.getElementById("filter");
plzField.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
console.log(event.target.value);
}
});
<input type="text" id="filter" />
Related Topics
Jquery Selector for Id Starts with Specific Text
Pass Parameters in Setinterval Function
What Is Returned from a Constructor
Angularjs 1.2 $Injector:Modulerr
Js:Convert Array of Strings to Array of Objects
How to Extend Function with Es6 Classes
How to Access Local Scope Dynamically in JavaScript
How to Detect When the Mouse Leaves the Window
Relation Between Commonjs, Amd and Requirejs
How to Find Indices of All Occurrences of One String in Another in JavaScript
Why Is {} + {} No Longer Nan in Chrome Console
Setting Query String Using Fetch Get Request
Create Svg Tag with JavaScript
How to Call Loading Function with React Useeffect Only Once
Dangerous Implications of Allman Style in JavaScript
How to Remove All Listeners in an Element
Why Does Array.Prototype.Push Return the New Length Instead of Something More Useful