I want to press any key on keyboard pro-grammatically using jquery. I have tried very hard but not successful.
HTML CODE
<input type="tel" name="org_contact_no" id="org_contact_no" maxlength="13" class="form-control">
JS CODE
FIRST ATTEMPT
setTimeout(function () {
$('#org_contact_no').trigger( "click");
}, 1000);
SECOND ATTEMPT
setTimeout(function() {
document.addEventListener('keypress', (event) => {
console.log('Meta Key?', event.metaKey);
console.log('Key Code', event.which);
});
document.dispatchEvent(new KeyboardEvent('keypress', {
metaKey: true, // On Windows, this is "window" key
keyCode: 44 // This is keyCode of comma on Windows-US
}))}, 1000);
Still don't have any luck.
I know its not a button. It's an input type="tel". I just want to press any key using 1 sec or XX sec.