How to get the correct key code when IME enabled?

In MyTextEdior (inherits from juce::TextEdior), I want do some punctuation-matching, see:

bool MyTextEditor::keyPressed (const KeyPress& key)
    // ...
    else if (key == KeyPress ('['))
        const String& selectedStr (getHighlightedText ());
        insertTextAtCaret ("[" + selectedStr + "]");

        if (selectedStr.isEmpty ())
            moveCaretLeft (false, false);

        return true;
    // ...

It works fine for all the English punctuations. but When I enabled IME (Chinese), I can’t get the correct key code, most of the key’s code and all the Chinese punctuations’ key code is 0…

What should I do?


…20 words…

What platform is this on? I’ve just tested this using the Mac ‘Keyboard Viewer’ as an input source with the language set to ‘Pinyin - Simplified’ and all the KeyPress objects have a valid key code associated with them.


Windows 7, 8, 10

Linux…Oh, JUCE can’t input any CJK text on Linux…

On Android, JUCE can input CJK text, but the result is very wrong or showed nothing…It’s no need to do any keypress test on that platform…