I have a query regarding sending an enter key stroke to an html element from chrome console.
First of all I have searched this forum already and found link
As explained, I have tried but my code is failing to click return key, hence this post.
My HTML:
<input type="text" class="arrow" onblur="inserttext('Enter company name or symbol',this);" onfocus="cleartext('Enter company name or symbol',this);" value="Enter company name or symbol" autocomplete="off" name="companyED" onkeydown="if(event.keyCode==13) return false;" onkeyup="onKeyUp(event,"keyword");" id="keyword">
What I have tried:
async function search(){
for(const val of x) {
let ele = document.getElementById('keyword');
ele.value = val;
console.log("Clicking: " + val);
ele.addEventListener("keyup", function(event) {
event.preventDefault();
if(event.keyCode === 13) {
console.log("in if");
ele.click();
}
});
};
}
Expected: Enter button should get hit
Actual: ReferenceError is throwing. Enter key is not working
Ofcourse I am calling my function as 'search()' in new line