aboutsummaryrefslogtreecommitdiff
path: root/src/background
diff options
context:
space:
mode:
Diffstat (limited to 'src/background')
-rw-r--r--src/background/index.js2
-rw-r--r--src/background/key-queue.js12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/background/index.js b/src/background/index.js
index 604ea92..d27c557 100644
--- a/src/background/index.js
+++ b/src/background/index.js
@@ -2,7 +2,7 @@ import * as actions from '../shared/actions';
import * as tabs from './tabs';
import KeyQueue from './key-queue';
-const queue = new KeyQueue();
+const queue = new KeyQueue(KeyQueue.DEFAULT_KEYMAP);
const keyDownHandle = (request) => {
return queue.push({
diff --git a/src/background/key-queue.js b/src/background/key-queue.js
index e21399e..666eec3 100644
--- a/src/background/key-queue.js
+++ b/src/background/key-queue.js
@@ -12,20 +12,20 @@ const DEFAULT_KEYMAP = [
export default class KeyQueue {
- constructor(keymap) {
+ constructor() {
this.data = [];
- this.keymap = keymap;
+ this.keymap = DEFAULT_KEYMAP;
}
push(key) {
this.data.push(key);
- let filtered = DEFAULT_KEYMAP.filter((map) => {
+ let filtered = this.keymap.filter((map) => {
return keys.hasPrefix(map.keys, this.data)
});
if (filtered.length == 0) {
this.data = [];
- return;
+ return null;
} else if (filtered.length == 1) {
let map = filtered[0];
if (map.keys.length == this.data.length) {
@@ -35,4 +35,8 @@ export default class KeyQueue {
}
return null;
}
+
+ queuedKeys() {
+ return this.data;
+ }
}