Recently I’ve changed my MacBook US keyboard to European one. Everything is fine with it except for the Tilda(~) key, which is located between Left Shift and Z keys on the EU keyboard, whereas usually it is located under Esc key on US and most PC keyboards. I do not know what was the purpose of this relocation or what historical background are behind it; I don’t care. What I care is that such location makes the use of Tilda key very annoying. And here is how I’ve solved it.
Editing Keyboard Layouts
If you want to swap the keys, you would think of altering the keyboard layout first. Good idea. It will even work. You can create new layouts with Ukelele, then put the layout files into “~/Library/Keyboard Layouts” or “/Library/Keyboard Layouts”. And they will appear in a list of available input sources in System Preferences as normal layouts.
Whatever you do, all your layouts will be the second-class citizens. The first-class citizens — so called “ASCII-capable” system layouts — will be required anyway all the times. You could not deselect the “U.S.” or any other first-class input source because it will be disabled (i.e, gray and unresponsive).
And even if you will mark you new layout as “Roman” with id “0” or “5000”, this will not help. Your hand-made layouts will never be treated as replacements for the built-in ones. More on that, if you’ll take a look at your logs, you will notice that Mac OS changes the id of the custom layout since it conflicts with the system’s one.
Jan 8 19:26:34 nolair com.apple.Finder: Keyboard Layouts: duplicate keyboard layout identifier 0. Jan 8 19:26:34 nolair com.apple.Finder: Keyboard Layouts: duplicate keyboard layout identifier 0. Jan 8 19:26:35 nolair com.apple.SystemUIServer.agent: Keyboard Layouts: duplicate keyboard layout identifier 0. Jan 8 19:26:35 nolair com.apple.SystemUIServer.agent: Keyboard Layouts: duplicate keyboard layout identifier 0.
And you cannot physically replace or substitute the system layouts, since they are stored in the files of unknown structure — “AppleKeyboardLayouts-B.dat” and “AppleKeyboardLayouts-L.dat” in “/System/Library/Keyboard Layouts/AppleKeyboardLayouts.bundle/Contents/Resources/”.
So, as in my case, you will end with three input sources: custom Russian layout, custom English layout, and system English layout. And sometimes you will be forced to this system layout when Mac OS X will decide to do so (for example, when you enter the passwords); or just randomly when you hold the switch button for a few more milliseconds than usually.
Believe me, you do not want to have this three-way in your workflow.
Remapping the Keys
The proper solution is to remap the keys. It really works with no additional mess (or I haven’t noticed it yet). Get and install KeyRemap4MacBook, install it. Then go to “System Preferences” and open “KeyRemap4MacBook”, which is located in “Other” section.
For Russian users
Find a section named “For Russian” (quite obvious), and check two marks:
- Backquote(`) to Paragraph(§)
- Paragraph(§) to Backquote(`)
Well, this is it. It will be in effect immediately.
Please note that the Backquote key will print square brackets (“[” and “]”) in Russian layout, which is an expected behavior — these symbols are drawn on the physical key, by the way. If you want the Backquote key to print backquote and tilda symbols both in English and in Russian modes, you have to make your own Russian keyboard layout (Ukelele will help with this).
For European users
Find a section named “For International English Keyboard and ISO Keyboard Users”, and check one of the marks, the one that you like more or less. Or, as for Russian users, check two marks:
- Backquote(`) to Section(§)
- Section(§) to Backquote(`)