Specific KeyPress problem


Hi there,
I have a problem with a specific keypress (shortcut for command) not being shown in the native OSX menu bar.
The following keypress does not show in the menu but does get executed, it does show fine in the Juce menu bar.
shift + command + !

You can easily reproduce it in the Juce Demo by changing the ‘Widgets’ keypress for example from:
result.addDefaultKeypress (T(‘3’), ModifierKeys::commandModifier);
result.addDefaultKeypress (T(’!’), ModifierKeys::commandModifier + ModifierKeys::shiftModifier);
Strange thing is shift + command + @ works fine.

Any clue on why this won’t work?

BTW, ‘shift + command + 1’, ‘shift + 1’ keypresses won’t work in OSX, they do in windows, this is just how OSX works.
Thought i mentioned for the ones that might be struggling to get those kind of keypresses to work in OSX.


Well, what’s the difference between “shift + 1” and “shift + !” ?

What’s the difference between “!” and “! + shift” ? How would I type “!” without shift?

As soon as you try using the shift modifier with anything other than a basic lower-case letter key, you’re asking for trouble!


Aren’t you grumpy today!
How do you explain then that shift + 1 doesn’t work at all using Juce in OSX?
How do you explain that every other combination does work instead of the ‘!’ ?
Did you at all had a proper look and modified the code in the Demo to see if there is a point in what i said?
Xcode display the shortcuts the with the ‘!’ or ‘@’, never with 1 or 2.

Take a look at what we discussed earlier.


Did that come across as grumpy? Sorry, it was supposed to sound playful, but I guess that didn’t work…!

I just wanted to make the point that a keypress like that is confusing and ambiguous, and that’s probably why OSX has a problem with it.

Rather than fix it, my preferred approach would be to just say it’s not allowed. Take the # key, for example - some keyboards require shift to press #, others require that you don’t press shift to get it. So you can’t ever use “shift + #” without problems, and I reckon the same rule should be applied to all the other similar symbols.


From my own experience it’s just best to stay neutral when answering someone questions. It’s good to be playful if someone gives you the incentive to do so.
Sorry if i overreacted.

Anyway, i still don’t have the feeling you understand the issue.
If you create a shortcut, lets’ say command + shift + 2 it does not work in Juce on OSX.
If you use command + shift + @, it does work, so what do you think i should do?
For me it’s sounds the most logical i should use command + shift + 1, that’s what i used the when following my instinct.
But Juce does not except it.

Please give it a shot and tell me i’m doing things wrong!

        case showWidgets:
            result.setInfo (T("Widgets"), T("Shows the widgets demo"), demosCategory, 0);
            result.setTicked (currentDemoId == showWidgets);
            result.addDefaultKeypress (T('1'), ModifierKeys::commandModifier + ModifierKeys::shiftModifier);


I just got the latest GIT version and compiled the Jucer.
Try this:
1 - open preferences
2 - go to the keys tab
3 - change one of the shortcuts and press the following keys ‘command’ + ‘shift’ + '1’
4 - the Jucer will show you ‘command + shift + !’ as the newly mapped shortcut.
This gives me the idea there might be a problem with translating keypresses in OSX.


Yes, it’s not at all surprising that it might be a problem to interpret those.

In ther Jucer it doesn’t really matter, because whatever key the user presses will obviously work fine on that machine, even if it’s shown on the screen in the wrong way.

But I don’t think there’s a fix for OSX - if you have a look, it uses a method called charactersIgnoringModifiers to get the key - if that’s returning ‘!’ then there’s nothing I can think of that could be done to figure out that it should really be a ‘1’…


- (NSString *)charactersIgnoringModifiers; /* the chars that would have been generated, regardless of modifier keys (except shift) */
Does this comment mean that it does take into account the shift key and thus returning ‘!’ instead of 1.

Ok, i wanna give up and i don’t at the same time.
It still puzzles me that i can’t use the command + shift + 1 in the menu, the rest of our interface is mappable, more or less like in Ableton Live. So you can set all shortcuts by clicking on the highlighted control and pressing the desired keys.
So all shortcuts work then.
When i press command + shift + 1 it displays command + shift + ! and all is working fine.
The only thing i can’t seem to get working is command + shift + 1 in the menu.
When i use the following line:

it displays the shortcuts fine in the menu but it doesn’t work.
when i use the this

it does not display the shortcut but does work.

If someone has any ideas let me know.


Please try this. Since “!” mean shift + 1, juce should be able to handle it.

result.addDefaultKeypress (T('!'), ModifierKeys::commandModifier);