I am trying to and have to keypress the letter 'A' with JavaScript.
In the code below, there is an alert('hello') box that indicates that the code is executing.
But this code doesn't set any values to the "login-email" input (which is a textbox).
What can be wrong with the code?
function presskey()
{
var e = document.createEvent('KeyboardEvent');
if (e.initKeyboardEvent)
{
alert('hello'); e.initKeyboardEvent('keypress', true, true, document.defaultView, 'A', 0, '', false, '');
}
document.getElementById('login-email').dispatchEvent(e);
}