How to properly trap Command+key presses?

I’ve got my key presses getting trapped, but I’m not sure how to properly determine which Command+key presses happened. When I hit Command and the ‘A’ key, the getKeyCode() returns 97 (lower case ‘a’), and getTextCharacter() returns L’a’, so I can use either and check for ‘a’ (after determining that isCommandDown() returned true). However, if I press Command and the ‘Z’ key, then getKeyCode() returns 90 (the capital ‘Z’!), while getTextCharacter() returns L’\0’, which isn’t anything useful that I can tell.

So, what is the proper way to detect Command+key presses, that works for all the usual combinations? I suppose I could check for ‘z’ OR ‘Z’, using the keyCode, but is that the way it’s intended to be checked?

Sorry, in what context are you trapping the key presses? CMD, like CTRL, ALT, and SHIFT, should be present as juce::ModifierKeys (whose state you can fetch at any point).

My Editor registers as a KeyListener, and I pass key press events to sub-components that (when enabled) handle those. In that code, one component handles Undo and Redo (and other Command+key) presses. I am finding it odd that Command+A differs from Command+Z (at least in Cubase on the Mac). I am detecting the Command being down fine, it’s the key pressed along with it that seems to be inconsistent in behavior.

I’m now using the keyCode, and checking against both the lower and upper case letters. Seems to be working, at least.