aboutsummaryrefslogtreecommitdiff
path: root/src/content/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/components')
-rw-r--r--src/content/components/common/index.js4
-rw-r--r--src/content/components/common/input.js11
-rw-r--r--src/content/components/common/keymapper.js4
3 files changed, 14 insertions, 5 deletions
diff --git a/src/content/components/common/index.js b/src/content/components/common/index.js
index 98a2337..db0ac43 100644
--- a/src/content/components/common/index.js
+++ b/src/content/components/common/index.js
@@ -10,8 +10,8 @@ export default class Common {
const input = new InputComponent(win.document.body, store);
const keymapper = new KeymapperComponent(store);
- input.onKey((key, ctrl) => follow.key(key, ctrl));
- input.onKey((key, ctrl) => keymapper.key(key, ctrl));
+ input.onKey(key => follow.key(key));
+ input.onKey(key => keymapper.key(key));
this.store = store;
this.children = [
diff --git a/src/content/components/common/input.js b/src/content/components/common/input.js
index 2de0d7d..9af9fbe 100644
--- a/src/content/components/common/input.js
+++ b/src/content/components/common/input.js
@@ -1,3 +1,10 @@
+const mapKey = (e) => {
+ if (e.ctrlKey) {
+ return '<C-' + e.key.toUpperCase() + '>';
+ }
+ return e.key;
+};
+
export default class InputComponent {
constructor(target) {
this.pressed = {};
@@ -47,8 +54,10 @@ export default class InputComponent {
return;
}
+ let key = mapKey(e);
+
for (let listener of this.onKeyListeners) {
- let stop = listener(e.key, e.ctrlKey);
+ let stop = listener(key);
if (stop) {
e.preventDefault();
e.stopPropagation();
diff --git a/src/content/components/common/keymapper.js b/src/content/components/common/keymapper.js
index 655c3f2..8c0ddb1 100644
--- a/src/content/components/common/keymapper.js
+++ b/src/content/components/common/keymapper.js
@@ -9,8 +9,8 @@ export default class KeymapperComponent {
update() {
}
- key(key, ctrl) {
- this.store.dispatch(inputActions.keyPress(key, ctrl));
+ key(key) {
+ this.store.dispatch(inputActions.keyPress(key));
let input = this.store.getState().input;
let matched = Object.keys(input.keymaps).filter((keyStr) => {