blob: e882a682d57427ff3f7d584504f92e60f82c9b43 (
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
32
33
|
import * as scrolls from './scrolls';
const invokeEvent = (action) => {
if (typeof action === 'undefined' || action === null) {
return;
}
switch (action[0]) {
case 'scroll.up':
scrolls.scrollUp(window, action[1] || 1);
break;
case 'scroll.down':
scrolls.scrollDown(window, action[1] || 1);
break;
}
}
window.addEventListener("keydown", (e) => {
let request = {
type: 'event.keydown',
code: e.keyCode,
shift: e.shift,
alt: e.alt,
meta: e.meta,
ctrl: e.ctrl,
}
browser.runtime.sendMessage(request)
.then(invokeEvent,
(err) => {
console.log(`Vim Vixen: ${err}`);
});
});
|