Creating a keystroke that is not possible with the current keyboard layout language

I see, thanks! I will experiment some more...

Does it work if you import the Action below (already set up with this keystroke)?

Type a Keystroke.kmactions (547 Bytes)

When I import the Action it immediatly changes the key:
That being said, it does work. But cmd+ΓΌ works anyway (see my reply to KeMa above).

That's because the .kmactions file includes the key code and not the character, which differs between keyboard layouts (ANSI: [ vs German: Ü):


The codes can be found here: Complete list of AppleScript key codes – but I doubt a solution can be found using this knowledge.

It's certainly the app Discord which does something problematic here. ← considering the observation that ⌘Ü and ⌘+ are apparently handled differently – maybe this fact could be pointed out to the Discord developers

1 Like

Hm, ⌘[ and ⌘] aren't mentioned anywhere among the Discord hotkeys, e.g.

Do you have a link to a page which describes them?

I actually cannot find it on their official site either right now, although I am sure I've seen it there before as well. But here is a screenshot from inside the Discord app's shortcut overview:

Have you tried βŒ₯← and βŒ₯β†’ (Go to next screen/ previous screen) and other combinations involving the arrow keys? One of them might do the same as ⌘[ and ⌘] with a bit of luck.

I have tried them. Unfortunately, no luck.

Better Touch Tool can solve your Problem

Please explain how exactly to solve the problem with BetterTouchTool. I do know this tool, but I haven't been able to think of a solution.

1 Like

Will try to get to my Mac in the evening and send you a screenshot.
BTT is highly recommended for all Mac users and I think it has a free trial.

screen shot from btt settings.
in this case i have set the computer to execute "command [" when i press "option 4" on a german keyboard.

hope that helps

you could also use Keyboard Maestro to run this applescript with a keyboard combination of your choice:

tell application "System Events"
   delay 0.2
   keystroke "[" using *command down*
end tell

I tried that and it doesn't seem to work, unfortunately.

But I will look into BTT, thanks!

Thank you @athmandest for trying to help, but I'm afraid BTT won't be able to do anything different than KM does here, too, i.e. generate key up and down events.

These events are apparently handled differently by the Discord app. The events for the key which is labeled [ on an ANSI but Ü on a German keyboard are used untranslated and trigger the desired action, while the events for the key labeled ] on ANSI but + on German keyboards are translated to mean + when the German keyboard mapping is in effect and not as ]. I.e. Discord prefers to execute the action associated with ⌘+ and not the ⌘] one desired here by the OP.

I'm afraid this problem cannot be solved without temporarily switching the keyboard layout between German and English. The question is if this temporary switch can be somehow done on a per-app basis, so that only Discord is affected by it, and/or if it can be sped up so that the macro will run quickly enough for a satisfactory experience.

@peternlewis, does macOS allow the keyboard layout to be switched only for a specific app or only for the duration of a keystroke? If so, the "Set Keyboard Layout" and the "Type a Keystroke" actions could be augmented in their cog wheel menu.


1 Like

it must be a discord thng then, because alt4 triggers the Play Sound macro on a german keyboard.

1 Like

I was going to suggest this. And with keystroke not working I'd say try keycode, again via AppleScript.

No. Karabiner Elements might be able to do that?

1 Like

How would that work? I know nothing about AppleScript, unfortunately.