INNER CODE UNIT · TypeScript
setBossKey
SimonAKing/scrcpy-gui · src/main/main.ts:272
function setBossKey(enabled: boolean, accelerator: string): OperationResult<string> {
if (registeredBossKey) {
globalShortcut.unregister(registeredBossKey)
registeredBossKey = ''
}
if (!enabled) return { ok: true, data: 'Boss key disabled.' }
const shortcut = accelerator.trim()
if (!shortcut) return operationFailure('BOSS_KEY_REQUIRED', 'validation', 'Enter a boss key shortcut.')
try {
const registered = globalShortcut.register(shortcut, () => {
stopAllScrcpy('boss-key')
mainWindow?.hide()
})
if (!registered) return operationFailure('BOSS_KEY_UNAVAILABLE', 'boss-key', `The shortcut ${shortcut} is already in use.`)
registeredBossKey = shortcut
return { ok: true, data: shortcut }
} catch (error) {