blob: 88a668e4eb6b69c8632b32c7d50d5aeafb771191 (
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
34
35
36
37
|
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) => {
if (e.target instanceof HTMLInputElement) {
return;
}
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}`);
});
});
|