You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
|
|
|
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}`);
|
|
|
|
});
|
|
|
|
});
|