aboutsummaryrefslogtreecommitdiff
path: root/src/content/index.js
blob: e77bb0a69313cbd1582b13dbb1de7d3f6563daaf (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
import * as scrolls from './scrolls';

const invokeEvent = (type) => {
  switch (type) {
  case 'scroll.up':
    scrolls.scrollUp(window);
    break;
  case 'scroll.down':
    scrolls.scrollDown(window);
    break;
  }
}

window.addEventListener("keypress", (e) => {
  browser.runtime.sendMessage({
    key: e.which || e.keyCode,
    shift: e.shift,
    alt: e.alt,
    meta: e.meta,
    ctrl: e.ctrl,
  }).then((response) => {
    if (response) {
      invokeEvent(response);
    }
  }, (err) => {
    console.log(`Vim Vixen: ${err}`);
  });
});