OS X Cocoa - 将虚拟扫描代码与 Char 相互转换
Windows 上是否有相当于 VkKeyScan 和 ToUnicode 函数的可可/碳,用于在虚拟扫描代码和 unicode 字符串之间进行转换?我还想反之亦然地执行此转换(从字符到扫描码)。
Is there a cocoa / carbon equivalent to the VkKeyScan and ToUnicode functions present on windows for translating between virtual scan codes and a unicode string? I would also like to perform this conversion vice versa (going from a char to a scan code).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可悲的是,我不确定是否存在。
CGEvent
和NSEvent
(不是免费桥接,但NSEvent
可以来回转换)是事件(包括按键)的标准容器,因此可以从设备相关的扫描代码进行转换到 unicode 字符串序列,但似乎没有办法走向另一个方向——从 unicode 字符到所需的设备相关按键序列。下面有一个简短的评论
CGEventCreateKeyboardEvent
表示:但是随后显示的序列对于 Shift 和 z 键具有硬编码且无法解释的常量。
I'm not sure there is, sadly.
CGEvent
andNSEvent
(which aren't toll-free bridged, butNSEvent
can convert back and forth) are the standard containers for events including key presses and as a result can convert from device-dependent scan codes to unicode string sequences but there seems to be no way to go in the other direction — from a unicode character to the required sequence of device-dependent key presses.There's a brief comment underneath
CGEventCreateKeyboardEvent
that:But the sequence shown then has hardcoded and unexplained constants for the shift and z keys.
UCKeyTranslate()
。UCKeyTranslate()
.