cocoabits / MASShortcut

Modern framework for managing global keyboard shortcuts compatible with Mac App Store. More details:
http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html
BSD 2-Clause "Simplified" License
1.52k stars 220 forks source link

Use NSEvent constants instead of hardcoded values #121

Closed davedelong closed 5 years ago

davedelong commented 6 years ago

MASShortcut.m has a switch statement inside -keyCodeStringForKeyEquivalent to translate a virtual key code into a user-facing string.

This method hard-codes a bunch of values, like 0xF704 for F1.

Instead of hard-coding these values, you should use the constants defined in NSEvent.h (down towards the bottom of the file), so 0xF704 would become NSF1FunctionKey, which would make its meaning much clearer.

It would also clarify the issue about guessing the value of higher-order function keys, since NSEvent defines values all the way up to a hypothetical “F35” key.

shpakovski commented 6 years ago

Hi Dave, thanks a lot for the problem report! 👍