gpt4 book ai didi

macos - UCKeyTranslate 对于键盘上的非 ascii 键返回垃圾信息

转载 作者:行者123 更新时间:2023-12-03 17:11:54 25 4
gpt4 key购买 nike

我正在尝试将键盘扫描码映射到 OSX 上的可显示字符串。

我在这里找到了该技术(Convert key code into key equivalent string),它适用于所有正常的ascii字母和数字,但对于所有其他键,即方向箭头、返回键等,我只是得到不可打印的字符。让我感到奇怪的是,所使用的 UCKeyTranslate 函数采用 UniChars 数组,但只返回单个字符。

我正在寻找类似于 Windows 上的 DirectInput DIPROP_KEYNAME 功能的东西。

我很难接受这样的事实:在当今的现代操作系统中,我将不得不对每个“不受支持”的键采用硬编码字符串值。

我有什么遗漏吗?

最佳答案

我无法保证您不必在代码中对这些值进行硬编码,但这个项目:

https://github.com/shpakovski/MASShortcut

就是这样:

// These glyphs are missed in Carbon.h
enum {
kMASShortcutGlyphEject = 0x23CF,
kMASShortcutGlyphClear = 0x2715,
kMASShortcutGlyphDeleteLeft = 0x232B,
kMASShortcutGlyphDeleteRight = 0x2326,
kMASShortcutGlyphLeftArrow = 0x2190,
kMASShortcutGlyphRightArrow = 0x2192,
kMASShortcutGlyphUpArrow = 0x2191,
kMASShortcutGlyphDownArrow = 0x2193,
kMASShortcutGlyphEscape = 0x238B,
kMASShortcutGlyphHelp = 0x003F,
kMASShortcutGlyphPageDown = 0x21DF,
kMASShortcutGlyphPageUp = 0x21DE,
kMASShortcutGlyphTabRight = 0x21E5,
kMASShortcutGlyphReturn = 0x2305,
kMASShortcutGlyphReturnR2L = 0x21A9,
kMASShortcutGlyphPadClear = 0x2327,
kMASShortcutGlyphNorthwestArrow = 0x2196,
kMASShortcutGlyphSoutheastArrow = 0x2198,
} MASShortcutGlyph;

希望这有帮助。

关于macos - UCKeyTranslate 对于键盘上的非 ascii 键返回垃圾信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21633147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com