mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-27 20:43:01 +03:00
fixed global shortcut behaviour (fixes #823)
This commit is contained in:
parent
596d75adc1
commit
cf83bd3798
@ -104,7 +104,11 @@ export class HotkeysService {
|
||||
item = (typeof item === 'string') ? [item] : item
|
||||
|
||||
try {
|
||||
this.electron.globalShortcut.register(item[0].replace(/-/g, '+'), () => {
|
||||
let electronKeySpec = item[0]
|
||||
electronKeySpec = electronKeySpec.replace('⌘', 'Command')
|
||||
electronKeySpec = electronKeySpec.replace('⌥', 'Alt')
|
||||
electronKeySpec = electronKeySpec.replace(/-/g, '+')
|
||||
this.electron.globalShortcut.register(electronKeySpec, () => {
|
||||
this.globalHotkey.emit()
|
||||
})
|
||||
} catch (err) {
|
||||
@ -131,7 +135,7 @@ export class HotkeysService {
|
||||
value = [value]
|
||||
}
|
||||
if (value) {
|
||||
value = value.map((item) => (typeof item === 'string') ? [item] : item)
|
||||
value = value.map(item => (typeof item === 'string') ? [item] : item)
|
||||
keys[key] = value
|
||||
}
|
||||
}
|
||||
|
@ -45,13 +45,12 @@ export function stringifyKeySequence (events: NativeKeyEvent[]): string[] {
|
||||
// TODO make this optional?
|
||||
continue
|
||||
}
|
||||
if (event.key === ' ') {
|
||||
itemKeys.push('Space')
|
||||
} else if (event.key.length === 1) {
|
||||
itemKeys.push(event.key.toUpperCase())
|
||||
} else {
|
||||
itemKeys.push(event.key)
|
||||
}
|
||||
|
||||
let key = (event as any).code
|
||||
key = key.replace('Key', '')
|
||||
key = key.replace('Arrow', '')
|
||||
key = key.replace('Digit', '')
|
||||
itemKeys.push(key)
|
||||
items.push(itemKeys.join('-'))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user