Keyboard
Spicetify.Keyboard registers global keyboard shortcuts through Spicetify.Mousetrap. In a module, use client.keyboard.
namespace Keyboard { const KEYS: Record<ValidKey, string>; function registerShortcut(keys: KeysDefine, callback: (event: KeyboardEvent) => void): void; function registerIsolatedShortcut(keys: KeysDefine, callback: (event: KeyboardEvent) => void): void; function registerImportantShortcut(keys: KeysDefine, callback: (event: KeyboardEvent) => void): void; function _deregisterShortcut(keys: KeysDefine): void; function deregisterImportantShortcut(keys: KeysDefine): void; function changeShortcut(keys: KeysDefine, newKeys: KeysDefine): void;}Shortcuts are global, so pick key combinations that Spotify and other modules do not use. keys is a KeysDefine. An invalid value throws.
KEYSmaps eachValidKeyto its Mousetrap name, soKEYS.CAPSis"capslock".registerShortcutbindscallbacktokeys.registerIsolatedShortcutandregisterImportantShortcutare aliases of it in v3._deregisterShortcutunbindskeys.deregisterImportantShortcutis an alias of it.changeShortcutmoves the callback bound tokeysontonewKeys, and throws whenkeyshas no binding.
Spicetify.Keyboard.registerShortcut({ key: 'p', ctrl: true, shift: true }, () => { Spicetify.showNotification('Shortcut pressed');});
Spicetify.Keyboard.changeShortcut( { key: 'p', ctrl: true, shift: true }, { key: 'o', ctrl: true, shift: true },);