mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-24 17:16:03 +00:00
fixed global shortcut behaviour (fixes #823)
This commit is contained in:
@@ -104,7 +104,11 @@ export class HotkeysService {
|
|||||||
item = (typeof item === 'string') ? [item] : item
|
item = (typeof item === 'string') ? [item] : item
|
||||||
|
|
||||||
try {
|
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()
|
this.globalHotkey.emit()
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -131,7 +135,7 @@ export class HotkeysService {
|
|||||||
value = [value]
|
value = [value]
|
||||||
}
|
}
|
||||||
if (value) {
|
if (value) {
|
||||||
value = value.map((item) => (typeof item === 'string') ? [item] : item)
|
value = value.map(item => (typeof item === 'string') ? [item] : item)
|
||||||
keys[key] = value
|
keys[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,13 +45,12 @@ export function stringifyKeySequence (events: NativeKeyEvent[]): string[] {
|
|||||||
// TODO make this optional?
|
// TODO make this optional?
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (event.key === ' ') {
|
|
||||||
itemKeys.push('Space')
|
let key = (event as any).code
|
||||||
} else if (event.key.length === 1) {
|
key = key.replace('Key', '')
|
||||||
itemKeys.push(event.key.toUpperCase())
|
key = key.replace('Arrow', '')
|
||||||
} else {
|
key = key.replace('Digit', '')
|
||||||
itemKeys.push(event.key)
|
itemKeys.push(key)
|
||||||
}
|
|
||||||
items.push(itemKeys.join('-'))
|
items.push(itemKeys.join('-'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user