use key-code

jh-changes
Shin'ya Ueoka 7 years ago
parent 6bdacc7758
commit e7342e9c23
  1. 10
      src/background/index.js
  2. 4
      src/content/index.js

@ -1,16 +1,16 @@
import * as tabs from './tabs';
const KEY_MAP = {
'tabs.prev': 104,
'tabs.next': 108,
'scroll.up': 107,
'scroll.down': 106
'tabs.prev': KeyboardEvent.DOM_VK_H,
'tabs.next': KeyboardEvent.DOM_VK_L,
'scroll.up': KeyboardEvent.DOM_VK_K,
'scroll.down': KeyboardEvent.DOM_VK_J
};
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
let response = null;
switch (request.key) {
switch (request.code) {
case KEY_MAP['tabs.prev']:
tabs.selectPrevTab(sender.tab.index);
break;

@ -11,9 +11,9 @@ const invokeEvent = (type) => {
}
}
window.addEventListener("keypress", (e) => {
window.addEventListener("keydown", (e) => {
browser.runtime.sendMessage({
key: e.which || e.keyCode,
code: e.keyCode,
shift: e.shift,
alt: e.alt,
meta: e.meta,