作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将键盘扫描码映射到 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/
我正在尝试将键盘扫描码映射到 OSX 上的可显示字符串。 我在这里找到了该技术(Convert key code into key equivalent string),它适用于所有正常的ascii字
我有以下测试代码: import Cocoa import Carbon let x = kUCKeyActionDisplay 在 Xcode 6.2 中没有问题,但在 Xcode 6.3 中这段代
我是一名优秀的程序员,十分优秀!