fixed combo delay
This commit is contained in:
parent
b8e5aa22b5
commit
e2b7a71c8e
2 changed files with 8 additions and 4 deletions
|
@ -16,6 +16,7 @@
|
|||
],
|
||||
"event": "EV_KEY",
|
||||
"type": "keydown",
|
||||
"delay": 3000,
|
||||
"command": "notify-send",
|
||||
"args": [
|
||||
"combo",
|
||||
|
|
|
@ -142,7 +142,8 @@ class Keyfilter {
|
|||
this.currentCombo = {
|
||||
key: key,
|
||||
type: event.type,
|
||||
start: new Date().getTime(),
|
||||
delay: event.delay,
|
||||
timestamp: new Date().getTime(),
|
||||
done: [key],
|
||||
remaining: JSON.parse(JSON.stringify(event.combo)),
|
||||
finished: this.hasComboFinished()
|
||||
|
@ -167,6 +168,7 @@ class Keyfilter {
|
|||
return false;
|
||||
}
|
||||
this.currentCombo.key = parsedEvent.key;
|
||||
this.currentCombo.timestamp = new Date().getTime();
|
||||
this.currentCombo.done.push(parsedEvent.key);
|
||||
this.currentCombo.remaining.shift();
|
||||
this.currentCombo.finished = this.hasComboFinished();
|
||||
|
@ -178,10 +180,11 @@ class Keyfilter {
|
|||
this.currentCombo.remaining.length === 0;
|
||||
}
|
||||
hasComboTimedOut() {
|
||||
return this.currentCombo !== undefined &&
|
||||
const result = this.currentCombo !== undefined &&
|
||||
this.currentCombo.delay !== undefined &&
|
||||
this.currentCombo.start !== undefined &&
|
||||
new Date().getTime() - this.currentCombo.start > this.currentCombo.delay;
|
||||
this.currentCombo.timestamp !== undefined &&
|
||||
new Date().getTime() - this.currentCombo.timestamp > this.currentCombo.delay;
|
||||
return result;
|
||||
}
|
||||
resetCurrentCombo() {
|
||||
this.currentCombo = undefined;
|
||||
|
|
Loading…
Reference in a new issue