mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-06 19:39:53 +00:00
fixed #4483 - repeat keydown events affecting hotkeys
This commit is contained in:
parent
2d331332a4
commit
7252f80573
@ -63,7 +63,7 @@ export class HotkeysService {
|
|||||||
private pressedHotkey: string|null = null
|
private pressedHotkey: string|null = null
|
||||||
private pressedKeystroke: Keystroke|null = null
|
private pressedKeystroke: Keystroke|null = null
|
||||||
private lastKeystrokes: PastKeystroke[] = []
|
private lastKeystrokes: PastKeystroke[] = []
|
||||||
private shouldSaveNextKeystroke = true
|
private recognitionPhase = true
|
||||||
private lastEventTimestamp = 0
|
private lastEventTimestamp = 0
|
||||||
|
|
||||||
private constructor (
|
private constructor (
|
||||||
@ -130,18 +130,20 @@ export class HotkeysService {
|
|||||||
const keyName = getKeyName(eventData)
|
const keyName = getKeyName(eventData)
|
||||||
if (eventName === 'keydown') {
|
if (eventName === 'keydown') {
|
||||||
this.addPressedKey(keyName, eventData)
|
this.addPressedKey(keyName, eventData)
|
||||||
this.shouldSaveNextKeystroke = true
|
if (!nativeEvent.repeat) {
|
||||||
|
this.recognitionPhase = true
|
||||||
|
}
|
||||||
this.updateModifiers(eventData)
|
this.updateModifiers(eventData)
|
||||||
}
|
}
|
||||||
if (eventName === 'keyup') {
|
if (eventName === 'keyup') {
|
||||||
const keystroke = getKeystrokeName([...this.pressedKeys])
|
const keystroke = getKeystrokeName([...this.pressedKeys])
|
||||||
if (this.shouldSaveNextKeystroke) {
|
if (this.recognitionPhase) {
|
||||||
this._keystroke.next(keystroke)
|
this._keystroke.next(keystroke)
|
||||||
this.lastKeystrokes.push({
|
this.lastKeystrokes.push({
|
||||||
keystroke,
|
keystroke,
|
||||||
time: performance.now(),
|
time: performance.now(),
|
||||||
})
|
})
|
||||||
this.shouldSaveNextKeystroke = false
|
this.recognitionPhase = false
|
||||||
}
|
}
|
||||||
this.removePressedKey(keyName)
|
this.removePressedKey(keyName)
|
||||||
}
|
}
|
||||||
@ -154,7 +156,7 @@ export class HotkeysService {
|
|||||||
|
|
||||||
const matched = this.matchActiveHotkey()
|
const matched = this.matchActiveHotkey()
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
if (matched) {
|
if (matched && this.recognitionPhase) {
|
||||||
this.emitHotkeyOn(matched)
|
this.emitHotkeyOn(matched)
|
||||||
} else if (this.pressedHotkey) {
|
} else if (this.pressedHotkey) {
|
||||||
this.emitHotkeyOff(this.pressedHotkey)
|
this.emitHotkeyOff(this.pressedHotkey)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user