在哪里可以找到与Cocoa的NSEvent类一起使用的关键代码列表? [英] Where can I find a list of key codes for use with Cocoa's NSEvent class?

查看:173
本文介绍了在哪里可以找到与Cocoa的NSEvent类一起使用的关键代码列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找可用于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.

推荐答案

据我所知,没有枚举或键列表。不过,要获得类似的行为,您可以调用 explainKeyEvents:在keyDown:将调用适当的动作方法,所有这些都记录在NSResponder中(例如 moveLeft: insertTab:,等)

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆