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

Let KeyCombo accept a key enum case #16

Closed
sindresorhus opened this issue Jul 13, 2018 · 2 comments
Closed

Let KeyCombo accept a key enum case #16

sindresorhus opened this issue Jul 13, 2018 · 2 comments

Comments

@sindresorhus
Copy link
Contributor

The API would be more developer friendly and Swifty if it also accepted an enum case as the key:

KeyCombo(key: .a, cocoaModifiers: [.command])
@1c7
Copy link

1c7 commented May 18, 2019

No Update?

By the way, soffes/HotKey have this kind of interface

Repo: https://github.com/soffes/HotKey

let hotKey = HotKey(key: .r, modifiers: [.command, .option])

But Hotkey doesn't work 😢

Magnet work. but document is not enough

if let keyCombo = KeyCombo(keyCode: 11, carbonModifiers: 4352) {
    let hotKey = HotKey(identifier: "CommandControlB", keyCombo: keyCombo, target: self, action: #selector(magnetKey))
    hotKey.register() // or HotKeyCenter.shared.register(with: hotKey)
}

@objc func magnetKey(){
    print("Magnet Work! \(Date())")
}

What carbonModifiers and keyCode mean? why it need "identifier: "CommandControlB""?

@Econa77
Copy link
Member

Econa77 commented Apr 30, 2020

@sindresorhus @1c7 The case with Enum is now supported 🎉( #44 )
We needed to consider keyboards that weren't QWERTY layouts, so I created a Sauce and it works for all keyboard layouts.

We will also be creating more documents such as the identifier.

@Econa77 Econa77 closed this as completed Apr 30, 2020
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

3 participants