I have a simple function that checks if CapsLock was on input
document.addEventListener('keydown', function(e) {
if(e.getModifierState("CapsLock")) {
console.log('CapsLock is on')
} else {
console.log('Capslock is off')
}
});
To test the function I tried to trigger it this way:
document.dispatchEvent(new KeyboardEvent('keydown', {key:'A', capsLockKey: true}));
But it's not working
How can I trigger new Keyboard Event with CapsLock property?