Swift-键代码键盘回程无法正常工作
使用物理键盘时,我的应用程序上有Hotkeys,除返回键外,所有键都可以正常工作。有理由或解决方法可以做出这项工作吗?谢谢。
extension testViewController {
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
guard let key = presses.first?.key else {return}
if key.keyCode == .keyboardReturn {
print("KEY PRESSED \(key.debugDescription)")
}
}
}
I have hotkeys on my app when using a physical keyboard and all the keys work fine except for the return key. Is there a reason why or a workaround to make this work? Thanks.
extension testViewController {
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
guard let key = presses.first?.key else {return}
if key.keyCode == .keyboardReturn {
print("KEY PRESSED \(key.debugDescription)")
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
返回有两个关键编码,它们是 .KeyboardReturn 和 .KeyboardReturnorenter
我只需要使用。当时没看到。
There are two keycodes for return which are .keyboardReturn and .keyboardReturnOrEnter
I just had to use .keyboardReturnOrEnter which I didn't see at the time.