Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is default keyboard shortcut has any bug? #113

Closed
pradeepb28 opened this issue Nov 28, 2022 · 2 comments
Closed

Is default keyboard shortcut has any bug? #113

pradeepb28 opened this issue Nov 28, 2022 · 2 comments

Comments

@pradeepb28
Copy link

pradeepb28 commented Nov 28, 2022

I have following keyboard shortcut that assigned a default value - Option + Tab but the observer doesn't gets called

extension KeyboardShortcuts.Name { 
    static let switch = Self("switch", default: .init(.tab, modifiers: [.option])) 
}

In App delegate I have an observer

func applicationDidFinishLaunching(_ aNotification: Notification) {
     KeyboardShortcuts.onKeyUp(for: .switch) {
            print("Option+Tab was pressed")
        }
}

by the way if the Option + Tab when set in Recorder field, it works fine but when it was assigned as default then no.

My question is

  • Is the above code enough to register a default keyboard shortcut? (I couldn't find much in the documentation in Readme file)

Any help is appreciated. Thank you.

@sindresorhus
Copy link
Owner

The default parameter means it will fill out the keyboard shortcut into the recorder initially. But if the recorder has already had a value, it will not fill out. I think the parameter is misnamed. It should have been named initial as that's what it is — It's the initial value before any value has been set by the user.

@pradeepb28
Copy link
Author

pradeepb28 commented Nov 28, 2022

In my case, I made sure that recorder doesn't have a value at all when setting default value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants