how can i dispatch a KeyboardEvent in window of pressing a keyboard key ? in javascript ? i have scenario in which user press and hold a specific keyboard button and then drag the mouse on screen it will draw a box , but i want to press that specific button programmatically on load of document , so whenever user will clickdown and drag mouse it will draw , is this possible ?
what is have a this keydown but its not working
window.dispatchEvent(new KeyboardEvent('keydown', {
'key': 'control'
}));