Unable to map \UA using DefaultKeyBinding.dict
-
25-05-2021 - |
Question
I am using a german Windows keyboard and want to map the key with <>|
on it to actually really write these symbols. Currently it writes
<>| without modifier: ^
<>| with option key: „
<>| with command or control: nothing
Using the app Key codes
I figured out that <>|
has a unicode of 0xA, so I tried these mappings in my DefaultKeyBinding.dict
:
"\UA" = ("insertText:", "<"); // forgot what this becomes
"$\UA" = ("insertText:", ">"); // becomes ° instead of <
"~\UA" = ("insertText:", "|"); // becomes „ instead of |
I commented right next to it what's the result after of course logging out and logging in again. Other key mappings work fine, I even disabled them during testing to make sure there are no conflicts.
Can anyone help me with this? What am I doing wrong? Is there any way to debug this?
Note: The key I am talking about can be seen here: https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg It is the key over the left windows key.
Update:
I think I found one part of the issue: I confused unicode code and key code. MacOS expects the unicode code, I gave the key code. The problem I have is that the Key Codes
app gives no unicode code for the key with <>|
on it, only a key code (0xA -> \UA in DefaultKeyBinding.dict
)
Update2: found the solution, see my answer below.
Solution 2
Seems I didn't finish the keyboard wizard for the new keyboard.
Went to settings - keyboard, there it popped up and it asked me exactly for the key right to the left shift key. That's exactly the key causing issues for me. I pressed that key, the wizard recommended me european keyboard layout, I accepted.
Voila, the key now writes < and with shift >. One thing that didnt work was writing the pipe symbol together with the option key.
I added this rule to DefaultKeyBinding.dict
:
"~<" = ("insertText:", "|");
Logged out and in, and now I can also write the pipe symbol with option key and the <>|
key.
Lesson learned: unicode code for a key depends on the chosen keyboard layout.
OTHER TIPS
An easy alternative is to make a custom layout with Ukelele. See if this one does what you need.