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).
Is there a cocoa / carbon equivalent to the VkKeyScan and ToUnicode functions present
Share
I’m not sure there is, sadly.
CGEventandNSEvent(which aren’t toll-free bridged, butNSEventcan 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
CGEventCreateKeyboardEventthat:But the sequence shown then has hardcoded and unexplained constants for the shift and z keys.