Device-specific modifier flags wrong when cmd key mapped to option in system prefs

Number:rdar://38343442 Date Originated:3/10/2018
Status: Resolved:
Product:macOS Product Version:10.13
Classification: Reproducible:Always

This must be done on a laptop. I tested it on a MacBook Pro. When you configure the command key to act as option, the left and right event modifier flags are wrong when pressing the command key (but right when pressing an option key).

I have received two reports from users of my app complaining about this.

Steps to Reproduce:

Go to system prefs > Keyboard > Keyboard. Click Modifier Keys…. Change Command (⌘) Key's setting to "⌥ Option".

Run the attached program in xcode, which logs the key event's modifier flags using NSLog.

Ensure the ModifierBug window has focus. Press left option, left command, right option, and right command and observe what is logged.

Expected Results:

Both left-side keys that act as option should log 80120; both right-side keys that act as option should log 80140.

In other words, all modifiers on the left side acting as option should send modifiers with NX_DEVICELCMDKEYMASK set and all modifiers on the right acting as option should send modifiers with NX_DEVICERCMDKEYMASK set.

Actual Results:
Left option: 80120
Left command: 80140
Right option: 80140
Right command: 80120

In other words, left- and rightness is swapped when pressing the command key when it is configured to act as option.


System Preferences > Keyboard > Keyboard > Modifier Keys > Command acts as Option. All other settings as defaults


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!