Is there a way to convert a unicode character to a Mac virtual keycode? (without building my own table?) It looks like on Windows there is VkKeyScanEx, but I'm not aware of a similar function for Cocoa on OS X.
有没有办法将unicode字符转换为Mac虚拟键码? (没有构建我自己的表?)看起来在Windows上有VkKeyScanEx,但我不知道OS X上的Cocoa有类似的功能。
I'm actually trying to do this for the iPad. I want to convert character taken from the keyboard and convert them into key codes, since the iPad keyboard won't supply keycodes.
我实际上是想为iPad做这件事。我想转换从键盘获取的字符并将其转换为键码,因为iPad键盘不提供键码。
2 个解决方案
#1
0
The ShortcutRecorder project on GoogleCode has an NSValueTransformer
subclass for converting strings to keycodes and vice versa, but I'm not sure if it'll work on iOS. It's a great place to start looking, though.
GoogleCode上的ShortcutRecorder项目有一个NSValueTransformer子类,用于将字符串转换为键码,反之亦然,但我不确定它是否适用于iOS。不过,这是一个开始寻找的好地方。
#2
0
I'm interested in the reason why it needs to be tagged iPhone/iPad — surely you can do all the conversion in OS X? Also, the iPhone/iPad "keyboard" is fundamentally a text input method (see UITextInput) —it's not that it "won't supply keycodes"; there simply aren't any (and what keycode/modifiers should it supply when you tap "A", hold for a bit, and pick a random accented version?).
我对它需要被标记为iPhone / iPad的原因感兴趣 - 当然你可以在OS X中进行所有转换吗?此外,iPhone / iPad“键盘”基本上是一种文本输入法(参见UITextInput) - 并不是说它“不会提供密钥代码”;根本没有任何(当你点击“A”时,它应该提供什么键码/修饰符,保持一点,并选择一个随机的重音版本?)。
If you're going to do this, test it on a variety of (odd) input methods on both the iPad and OS X. If there's an API to insert a string, do so (but this might not work so well for games which read scan codes...). You could even write a custom input method extension which accepted Unicode strings.
如果您要这样做,请在iPad和OS X上的各种(奇数)输入方法上进行测试。如果有一个API要插入字符串,请执行此操作(但这可能不适用于游戏,读取扫描码...)。您甚至可以编写一个接受Unicode字符串的自定义输入法扩展。
It's debatable what should happen when a Dvorak VNC client types to a QWERTY VNC server...
当Dvorak VNC客户端输入QWERTY VNC服务器时会发生什么事情值得商榷......
I'll end with a tangential story:
我将以一个切向的故事结束:
A little over a year ago (before I got an iPhone), I got a N810. If anything, it makes a half-decent SSH/VNC client and has a decent keyboard.
一年多前(在我拿到iPhone之前),我买了一台N810。如果有的话,它会成为一个不错的SSH / VNC客户端并拥有一个不错的键盘。
Except it's not a standard keyboard. 1 is Fn-Q and ! is Fn-A, but when I type Fn-A to get "!", the VNC server ends up typing "1". Typing Shift-Fn-A gives me the "!" I was looking for (I think Shift-Fn-Q also works).
除了它不是标准键盘。 1是Fn-Q和!是Fn-A,但当我输入Fn-A得到“!”时,VNC服务器最终输入“1”。键入Shift-Fn-A给我“!”我一直在寻找(我认为Shift-Fn-Q也有效)。
Something, somewhere, parses the character "!", decides that it has the same scan code as "1", and types the scan code for 1 with no modifier. It could automatically hold down Shift. It might even be able to insert a string. Instead, it just fails.
在某处,某个地方解析字符“!”,确定它与“1”具有相同的扫描码,并在没有修饰符的情况下键入1的扫描码。它可以自动按住Shift。它甚至可以插入一个字符串。相反,它只是失败了。
#1
0
The ShortcutRecorder project on GoogleCode has an NSValueTransformer
subclass for converting strings to keycodes and vice versa, but I'm not sure if it'll work on iOS. It's a great place to start looking, though.
GoogleCode上的ShortcutRecorder项目有一个NSValueTransformer子类,用于将字符串转换为键码,反之亦然,但我不确定它是否适用于iOS。不过,这是一个开始寻找的好地方。
#2
0
I'm interested in the reason why it needs to be tagged iPhone/iPad — surely you can do all the conversion in OS X? Also, the iPhone/iPad "keyboard" is fundamentally a text input method (see UITextInput) —it's not that it "won't supply keycodes"; there simply aren't any (and what keycode/modifiers should it supply when you tap "A", hold for a bit, and pick a random accented version?).
我对它需要被标记为iPhone / iPad的原因感兴趣 - 当然你可以在OS X中进行所有转换吗?此外,iPhone / iPad“键盘”基本上是一种文本输入法(参见UITextInput) - 并不是说它“不会提供密钥代码”;根本没有任何(当你点击“A”时,它应该提供什么键码/修饰符,保持一点,并选择一个随机的重音版本?)。
If you're going to do this, test it on a variety of (odd) input methods on both the iPad and OS X. If there's an API to insert a string, do so (but this might not work so well for games which read scan codes...). You could even write a custom input method extension which accepted Unicode strings.
如果您要这样做,请在iPad和OS X上的各种(奇数)输入方法上进行测试。如果有一个API要插入字符串,请执行此操作(但这可能不适用于游戏,读取扫描码...)。您甚至可以编写一个接受Unicode字符串的自定义输入法扩展。
It's debatable what should happen when a Dvorak VNC client types to a QWERTY VNC server...
当Dvorak VNC客户端输入QWERTY VNC服务器时会发生什么事情值得商榷......
I'll end with a tangential story:
我将以一个切向的故事结束:
A little over a year ago (before I got an iPhone), I got a N810. If anything, it makes a half-decent SSH/VNC client and has a decent keyboard.
一年多前(在我拿到iPhone之前),我买了一台N810。如果有的话,它会成为一个不错的SSH / VNC客户端并拥有一个不错的键盘。
Except it's not a standard keyboard. 1 is Fn-Q and ! is Fn-A, but when I type Fn-A to get "!", the VNC server ends up typing "1". Typing Shift-Fn-A gives me the "!" I was looking for (I think Shift-Fn-Q also works).
除了它不是标准键盘。 1是Fn-Q和!是Fn-A,但当我输入Fn-A得到“!”时,VNC服务器最终输入“1”。键入Shift-Fn-A给我“!”我一直在寻找(我认为Shift-Fn-Q也有效)。
Something, somewhere, parses the character "!", decides that it has the same scan code as "1", and types the scan code for 1 with no modifier. It could automatically hold down Shift. It might even be able to insert a string. Instead, it just fails.
在某处,某个地方解析字符“!”,确定它与“1”具有相同的扫描码,并在没有修饰符的情况下键入1的扫描码。它可以自动按住Shift。它甚至可以插入一个字符串。相反,它只是失败了。