1

Expectations:

I want to dispatch multiple keypress events simutamusly. For example, I want my test to simulate a shift+tab event with

The code :

...
describe("ESC press", () => {

// How do i use this dispatch event to simulate a key press of shift+tab 

    document.dispatchEvent(escapeEvent)
    });
...
tg marcus
  • 157
  • 2
  • 13

1 Answers1

0

Use this technique twice to simulate multiple hold key events :

const shift = new KeyboardEvent('keydown', {'keyCode': 16});
document.dispatchEvent(event);

const tab = new KeyboardEvent('keydown', {'keyCode': 9});
document.dispatchEvent(event);

Cheers

l -_- l
  • 618
  • 4
  • 15