在哪里可以找到与Cocoa的NSEvent类一起使用的关键代码的列表? [英] Where can I find a list of key codes for use with Cocoa's NSEvent class?
问题描述
我正在寻找可用于Cocoa的 NSEvent
类的关键代码的全面列表。 NSEvent
类有一个 keyCode
属性,定义为 unsigned short
。以下代码放置在适当的UI对象中时,会按键按下代码:
I'm looking for a comprehensive list of the available key codes that can be used with Cocoa's NSEvent
class. The NSEvent
class has a keyCode
property, which is defined as unsigned short
. The following code, when placed in an appropriate UI object, will echo the key codes as they are pressed:
- (void)keyDown:(NSEvent *)theEvent
{
NSLog(@"%d", [theEvent keyCode]);
}
从这段代码,我可以很容易地看到哪些代码与某些键匹配,但是想找到列出所有这些文件的官方文档。我希望苹果有一个头文件,看起来像这样:
From this code, I can easily see which codes match certain keys, but I would like to find an official document somewhere that lists all of them. I expected Apple to have a header file somewhere that looked like this:
enum {
...
NSKeyCodeLeftArrow = 123,
NSKeyCodeRightArrow = 124,
...
};
但如果有一个,我还没有找到。
But if there is one, I have yet to find it.
推荐答案
据我所知,没有枚举或密钥代码列表。但是,为了获得类似的行为,您可以调用 interpretKeyEvents:在keyDown中:这将调用适当的操作方法,所有这些都在NSResponder中记录(例如 moveLeft:, insertTab :,etc。)
As far as I know, there is no enum or list of key codes. However, to get similar behavior, you can call interpretKeyEvents: in keyDown: which will call appropriate action methods, all of which are documented in NSResponder (e.g. moveLeft:, insertTab:, etc.)
这篇关于在哪里可以找到与Cocoa的NSEvent类一起使用的关键代码的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!