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?

Answered by DTS Engineer in 782815022

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"

Accepted Answer

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"

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