This repository has been archived on 2020-04-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Vim-Vixen/e2e/ambassador/src/client/keys.js
2018-06-28 21:26:48 +09:00

28 lines
659 B
JavaScript

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({ ...modifiers,
type: EVENT_KEYPRESS,
tabId,
key, });
};
const down = (tabId, key, modifiers = NEUTRAL_MODIFIERS) => {
return ipc.send({ modifiers,
type: EVENT_KEYDOWN,
tabId,
key, });
};
const up = (tabId, key, modifiers = NEUTRAL_MODIFIERS) => {
return ipc.send({ modifiers,
type: EVENT_KEYUP,
tabId,
key, });
};
export { press, down, up };