GithubHelp home page GithubHelp logo

cleanshavenapps / shortcutrecorder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kentzo/shortcutrecorder

0.0 1.0 0.0 2.11 MB

The best control to record shortcuts on macOS, written in ObjC with Swift in mind

License: Other

Objective-C 65.63% Ruby 0.23% Swift 33.86% Python 0.28%

shortcutrecorder's Introduction

CC BY 4.0 macOS 10.11 Mac App Store Approved

CocoaPods Compatible Carthage Compatible

Coverage Build Status

ShortcutRecorder

Showcase

The best control to record shortcuts on macOS

  • Objective-C framework developed with Swift in mind
  • Easily stylable
  • Translated into 22 languages
  • Supports macOS Accessibility
  • Thoroughly documented and tested
  • Global and Local shortcuts for both key up and key down actions
  • Mac App Store approved
  • End-to-end Interface Builder integration

What is inside

The framework comes with:

  • SRRecorderControl to render and capture user input
  • SRRecorderControlStyle for custom styling
  • SRShortcut that represents a shortcut model
  • SRGlobalShortcutMonitor to turn the shortcut into an action by registering a global hot key
  • SRAXGlobalShortcutMonitor to handle any kind of keyboard event via Accessibility
  • SRLocalShortcutMonitor for manual handling in the responder chain and NSEvent monitors
  • SRShortcutController for smooth Cocoa Bindings and seamless Interface Builder integration
  • SRShortcutValidator to check validity of the shortcut against Cocoa key equivalents and global hot keys
  • NSValueTransformer and NSFormatter subclasses for custom alterations

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"];

Integration

The framework supports module maps, explicit linking is not required: simply import ShortcutRecorder / #import <ShortcutRecorder/ShortcutRecorder.h>

Swift Package Manager

.package(url: "git://github.com/Kentzo/ShortcutRecorder.git", from: "3.3.0")

CocoaPods

pod 'ShortcutRecorder', '~> 3.3.0'

Carthage

github "Kentzo/ShortcutRecorder" ~> 3.3.0

Prebuilt frameworks are available via GitHub releases.

Git Submodule

git submodule add git://github.com/Kentzo/ShortcutRecorder.git

Then drag'n'drop into Xcode workspace of your project.

Next Steps

  • The Documentation playground covers all parts of the framework (see in Xcode)
  • The Inspector app is useful during development of custom styles
  • Read about Styling and special notes regarding Cocoa's Key Equivalents.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.