我制作了一个Swift 包,使这变得非常简单:
\nimport KeyboardShortcuts\n\nextension KeyboardShortcuts.Name {\n static let startFiveRounds = Self("startFiveRounds", default: .init(.t, modifiers: [.command, .option]))\n}\n\n@main\nfinal class AppDelegate: NSObject, NSApplicationDelegate {\n func applicationDidFinishLaunching(_ notification: Notification) {\n KeyboardShortcuts.onKeyUp(for: .startFiveRounds) {\n // \xe2\x80\xa6\n }\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n尽管您已经解决了您的问题,但我认为这对于其他遇到相同问题的人可能很有用。
\n我还建议让用户选择自己的键盘快捷键,而不是对其进行硬编码。我的包附带一个控件,用户可以在其中设置他们喜欢的快捷方式。
\n| 归档时间: |
|
| 查看次数: |
836 次 |
| 最近记录: |