Merge branch ‘develop’
The best control to record shortcuts on macOS
The framework comes with:
SRRecorderControl
SRRecorderControlStyle
SRShortcut
SRGlobalShortcutMonitor
SRAXGlobalShortcutMonitor
SRLocalShortcutMonitor
NSEvent
SRShortcutController
SRShortcutValidator
NSValueTransformer
NSFormatter
In Swift:
import ShortcutRecorder let defaults = NSUserDefaultsController.shared let keyPath = "values.shortcut" let options = [NSBindingOption.valueTransformerName: .keyedUnarchiveFromDataTransformerName] let beepAction = ShortcutAction(keyPath: keyPath, of: defaults) { _ in NSSound.beep() return true } GlobalShortcutMonitor.shared.addAction(beepAction, forKeyEvent: .down) let recorder = RecorderControl() recorder.bind(.value, to: defaults, withKeyPath: keyPath, options: options) recorder.objectValue = Shortcut(keyEquivalent: "⇧⌘A")
In Objective-C:
#import <ShortcutRecorder/ShortcutRecorder.h> NSUserDefaultsController *defaults = NSUserDefaultsController.sharedUserDefaultsController; NSString *keyPath = @"values.shortcut"; NSDictionary *options = @{NSValueTransformerNameBindingOption: NSKeyedUnarchiveFromDataTransformerName}; SRShortcutAction *beepAction = [SRShortcutAction shortcutActionWithKeyPath:keyPath ofObject:defaults actionHandler:^BOOL(SRShortcutAction *anAction) { NSBeep(); return YES; }]; [[SRGlobalShortcutMonitor sharedMonitor] addAction:beepAction forKeyEvent:SRKeyEventTypeDown]; SRRecorderControl *recorder = [SRRecorderControl new]; [recorder bind:NSValueBinding toObject:defaults withKeyPath:keyPath options:options]; recorder.objectValue = [SRShortcut shortcutWithKeyEquivalent:@"⇧⌘A"];
The framework supports module maps, explicit linking is not required: simply import ShortcutRecorder / #import <ShortcutRecorder/ShortcutRecorder.h>
import ShortcutRecorder
#import <ShortcutRecorder/ShortcutRecorder.h>
.package(url: "git://github.com/Kentzo/ShortcutRecorder.git", from: "3.4.0")
pod 'ShortcutRecorder', '~> 3.4.0'
github "Kentzo/ShortcutRecorder" ~> 3.4.0
Prebuilt frameworks are available via GitHub releases.
git submodule add git://github.com/Kentzo/ShortcutRecorder.git
Then drag’n’drop into Xcode workspace of your project.
Still have questions? Create an issue.
Paid support is available for custom alterations, help with integration and general advice regarding development for Apple’s platforms.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
ShortcutRecorder
The best control to record shortcuts on macOS
What is inside
The framework comes with:
SRRecorderControl
to render and capture user inputSRRecorderControlStyle
for custom stylingSRShortcut
that represents a shortcut modelSRGlobalShortcutMonitor
to turn the shortcut into an action by registering a global hot keySRAXGlobalShortcutMonitor
to handle any kind of keyboard event via AccessibilitySRLocalShortcutMonitor
for manual handling in the responder chain andNSEvent
monitorsSRShortcutController
for smooth Cocoa Bindings and seamless Interface Builder integrationSRShortcutValidator
to check validity of the shortcut against Cocoa key equivalents and global hot keysNSValueTransformer
andNSFormatter
subclasses for custom alterationsIn Swift:
In Objective-C:
Integration
The framework supports module maps, explicit linking is not required: simply
import ShortcutRecorder
/#import <ShortcutRecorder/ShortcutRecorder.h>
Swift Package Manager
CocoaPods
Carthage
Prebuilt frameworks are available via GitHub releases.
Git Submodule
Then drag’n’drop into Xcode workspace of your project.
Next Steps
Questions
Still have questions? Create an issue.
Paid Support
Paid support is available for custom alterations, help with integration and general advice regarding development for Apple’s platforms.