aboutsummaryrefslogtreecommitdiff
path: root/e2e/ambassador/src/content/events.js
blob: 1e459099bcd805a2fee78f1fa0a7a07cb369f9d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const keypress = (opts) => {
  let event = new KeyboardEvent('keypress', {
    key: opts.key,
    altKey: opts.altKey,
    shiftKey: opts.shiftKey,
    ctrlKey: opts.ctrlKey
  });
  document.body.dispatchEvent(event);
};

const keydown = (opts) => {
  let event = new KeyboardEvent('keydown', {
    key: opts.key,
    altKey: opts.altKey,
    shiftKey: opts.shiftKey,
    ctrlKey: opts.ctrlKey
  });
  document.body.dispatchEvent(event);
};

const keyup = (opts) => {
  let event = new KeyboardEvent('keyup', {
    key: opts.key,
    altKey: opts.altKey,
    shiftKey: opts.shiftKey,
    ctrlKey: opts.ctrlKey
  });
  document.body.dispatchEvent(event);
};

export { keypress, keydown, keyup };