Search code examples
objective-cxcodemacosstandards

What is the keycode for Clear and Equal on the Numpad on Mac?


I need to know what the keycode is for the clear and the equal key on the numpad.

enter image description here

I've seen different sources explain it, but they all say something different. Can someone give me a definite answer?

Update:

I get the keycodes this way:

NSEvent *result = incomingEvent;
unichar key = result.keyCode;

Which makes the equal sign on the numpad to be 81 and the normal equal sign to be 24.

How do I get the keycodes you are talking about?


Solution

  • The file

    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h
    

    contains constants for virtual keycodes, in particular

    kVK_ANSI_Equal                = 0x18
    kVK_ANSI_KeypadClear          = 0x47
    kVK_ANSI_KeypadEquals         = 0x51
    

    Since the code for the equal sign is the same that you obtained from NSEvent these definitions seem to be what you need.