Answers for "dispatch keydown event javascript"

0

dispatch keydown event javascript

element.dispatchEvent(new KeyboardEvent('keydown', {'key':'Shift'} ));
element.dispatchEvent(new KeyboardEvent( 'keyup' , {'key':'Shift'} )); //To mimic keypress 

//More complete example
//https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent
element.dispatchEvent(new KeyboardEvent("keydown", {
    key: "e",
    keyCode: 69, 
    code: "KeyE", 
    which: 69,
    shiftKey: false, 
    ctrlKey: false,  
    metaKey: false   
}));
Posted by: Guest on October-19-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language