Where can I found a list of codes for NSEvent.keyCode

According to the doc:

The value returned is the same as the value returned in the kEventParamKeyCode when using Carbon Events.

So where can I find kEventParamKeyCode?

Accepted Reply

IIRC these are the virtual key codes, which are defined in <HIToolbox/Events.h>, where HIToolbox is a subframework within Carbon. In Swift you can access these like so

import Carbon

print(kVK_Return)   // 36

If you have aversion to importing Carbon, it’d be reasonable to define your own constants for these. The virtual key codes are tied to hardware (namely Apple’s ADB keyboards) and thus can’t change.

You should also file a bug requesting that these be made available within importing Carbon. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • I don't believe it's a bug. It's simply that I didn't know where to find the predefined key codes. import Carbon.HIToolbox does the job.

Add a Comment

Replies

IIRC these are the virtual key codes, which are defined in <HIToolbox/Events.h>, where HIToolbox is a subframework within Carbon. In Swift you can access these like so

import Carbon

print(kVK_Return)   // 36

If you have aversion to importing Carbon, it’d be reasonable to define your own constants for these. The virtual key codes are tied to hardware (namely Apple’s ADB keyboards) and thus can’t change.

You should also file a bug requesting that these be made available within importing Carbon. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • I don't believe it's a bug. It's simply that I didn't know where to find the predefined key codes. import Carbon.HIToolbox does the job.

Add a Comment