Migrate from Magnet to KeyboardShortcuts
mainWhen migrating from Magnet, note that Magnet fires on key-down by default. To maintain the same behavior in KeyboardShortcuts, filter your event loop for .keyDown.
Value Migration
If you persisted KeyCombo values manually, convert them using a helper that provides the carbon key code and modifiers.
import KeyboardShortcuts
func migrateLegacyShortcut(
newName: KeyboardShortcuts.Name,
readLegacyCarbonValue: () -> (Int, Int)?
) {
guard KeyboardShortcuts.getShortcut(for: newName) == nil else {
return
}
guard let (carbonKeyCode, carbonModifiers) = readLegacyCarbonValue() else {
return
}
KeyboardShortcuts.setShortcut(.init(carbonKeyCode: carbonKeyCode, carbonModifiers: carbonModifiers), for: newName)
}