I am trying to fire keydown
event using synthetic new KeyboardEvent()
on Microsoft Edge (not IE) browser but not able to set keyCode
property.
Actually, I want to simulate down arrow keydown
event.
const event = new KeyboardEvent('keydown', {
code : 'Down',
key: 'Down',
keyCode: 40,
} as KeyboardEventInit));
but when I dispatch this event and logs the output event, the keyCode
property always returns to be 0 instead of 40.
The above code works on Chrome, Firefox, and Safari. Correct me if I am doing anything wrong.