检测活动键盘是否在Swift中具有物理`fn`键
我想使用 fn
修改器密钥(如果有),如果没有,请为用户提供其他修饰符。但是,仅将其提供给没有 fn
密钥的用户。某些外部键盘没有 fn
键。
有什么方法可以检测活动键盘是否具有物理 fn
键?
(我不问如何检测 fn
钥匙按)
我正在寻找Swift中的解决方案,该解决方案在沙盒应用程序中起作用。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要回答这个问题,我将解释该策略,但是即使有办法,也可能不值得这样做。
有些情况要考虑:
到我们没有任何API可悲地检查物理按钮的存在,但是我们确实有:
显然考虑到这些API在沙盒环境中可用,我们可以制作一个详尽的数据库。我们还可以将列表限制在流行模型中以使其更小。
从UX的角度来看,这就是一个例子。过去,在Windows键盘上,我们曾经有此键:
但并非所有键盘都具有它,因此要补偿, shift + f10 相同的。仍然在Windows 11中做。
或者,如果您为用户写了通知,则显示替代方案非常常见:
我建议我建议采用类似的方法去。
To answer the question I'll explain the strategy but even if there is a way, it's probably not worth going for it.
Some cases to consider:
Across the board we don't have any APIs to check for physical button presence sadly, but we do have:
Obviously considering that these APIs are available in a sandboxed environment, we can make an exhaustive database. We can also limit the list to popular models to make it smaller.
From a UX perspective though, here is an example. On Windows keyboards in the past we used to have this key:
But not all keyboards had it, so to compensate, Shift+F10 does the same. Still does in Windows 11.
Or if you're writing a notification for the user, it's very common to show the alternatives:
I'd recommend going with a similar approach instead.