Ignore reserved keybindings when typing in text input (#2514)

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
This commit is contained in:
bymyself
2025-02-12 09:15:19 -07:00
committed by GitHub
parent 150b4341b2
commit 46f0733ae7
4 changed files with 71 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ import _ from 'lodash'
import { defineStore } from 'pinia'
import { Ref, computed, ref, toRaw } from 'vue'
import { RESERVED_BY_TEXT_INPUT } from '@/constants/reservedKeyCombos'
import { KeyCombo, Keybinding } from '@/types/keyBindingTypes'
export class KeybindingImpl implements Keybinding {
@@ -76,6 +77,23 @@ export class KeyComboImpl implements KeyCombo {
return ['Control', 'Meta', 'Alt', 'Shift'].includes(this.key)
}
get modifierCount(): number {
const modifiers = [this.ctrl, this.alt, this.shift]
return modifiers.reduce((acc, cur) => acc + Number(cur), 0)
}
get isShiftOnly(): boolean {
return this.shift && this.modifierCount === 1
}
get isReservedByTextInput(): boolean {
return (
!this.hasModifier ||
this.isShiftOnly ||
RESERVED_BY_TEXT_INPUT.has(this.toString())
)
}
getKeySequences(): string[] {
const sequences: string[] = []
if (this.ctrl) {