flush input queue when no key-maps matched

This commit is contained in:
Shin'ya Ueoka 2017-08-13 12:24:55 +09:00
parent 082450928a
commit 3c1b33add3
2 changed files with 24 additions and 9 deletions

View file

@ -17,10 +17,18 @@ export default class KeyQueue {
push(key) {
this.data.push(key);
for (let map of DEFAULT_KEYMAP) {
if (keys.keysEquals(map.keys, this.data)) {
let filtered = DEFAULT_KEYMAP.filter((map) => {
return keys.hasPrefix(map.keys, this.data)
});
if (filtered.length == 0) {
this.data = [];
return;
} else if (filtered.length == 1) {
let map = filtered[0];
if (map.keys.length == this.data.length) {
this.data = [];
return map.action
return map.action;
}
}
return null;