This issue is very annoying when “Korean 2-Set Keyboard” is selected as the input source. For example, when entering a number or space character, the KeyUp event behaves like a KeyDown event, so the input is doubled, once on KeyDown and once on KeyUp.
The same problem occurs when I select a third-party open-source MAC Korean IME, so I investigated its source, but I couldn't find any suspicious code.
My conclusion is that if the ime is not in composition (in other words, hasMarkedText is FALSE), NSTextInputContext::handleEvent treats KeyUp events like KeyDown. When I tested a specialized Japanese key sequence that satisfied this condition, I was able to reproduce the same issue with Japanese IMEs.
As you describe, all the NSTextInputContext documentation I researched seemed to only be interested in KeyDown events. Unfortunately, I couldn't find any documentation that explicitly talked about handling KeyUp events. I wasn't sure if this was a macOS bug or intended, so my work stalled.
As a compromise, I tried to think about it from a different perspective.
1. For a long time, winemac ime did not handle KeyUp events. 2. This issue occurs after commit faa342a2f168. 3. However, commit faa342a2f168 itself is correct. 4. as far as I know, there hasn't been any issue that NSTextInputContext:handleEvent should handle KeyUp events.
Therefore, my opinion is that a fix like this MR with commit faa342a2f168 is not unreasonable.
In addition to this issue, Korean input is currently broken in Wine macOS build. If this issue is fixed, I would like to try upstream.