aboutsummaryrefslogtreecommitdiff
path: root/e2e/ambassador/src/client/keys.js
blob: 37b9c0a08912d0c2e92d6fe1aa698fd5c2a98ccc (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
import { EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP } from '../shared/messages';
import * as ipc from './ipc';

const NEUTRAL_MODIFIERS = { shiftKey: false, altKey: false, ctrlKey: false };

const press = (tabId, key, modifiers = NEUTRAL_MODIFIERS) => {
  return ipc.send(Object.assign({}, modifiers, {
    type: EVENT_KEYPRESS,
    tabId,
    key,
  }));
};

const down = (tabId, key, modifiers = NEUTRAL_MODIFIERS) => {
  return ipc.send(Object.assign({}, modifiers, {
    type: EVENT_KEYDOWN,
    tabId,
    key,
  }));
};


const up = (tabId, key, modifiers = NEUTRAL_MODIFIERS) => {
  return ipc.send(Object.assign({}, modifiers, {
    type: EVENT_KEYUP,
    tabId,
    key,
  }));
};

export { press, down, up };