1

I am using a British IBM model M keyboard with Mountain Lion. I have selected the "British - PC" input source and it is working well, except for one key: the pipe.

If you consider what is printed on the key-caps to be correct then the keyboard is mapped correctly, but there is one difference to what my muscle-memory expects and how the keyboard works in Linux.

The key with the "¦" symbol (a "broken pipe"?) on it lies immediately to the right of the left-shift key. I am used to getting a "|" symbol (the "pipe") if I use this key with the "Shift" key.

The key with the "|" symbol is the one immediately to the left of the number 1 key. It emits a "|" symbol when used with the "Alt" key.

Now, I would like to press the key immediately to the right of the left-shift key (marked "¦") and to get a pipe "|" output when used with the "Shift" key.

I have tried using the OSX "symbol and text substitution" feature and this works, except it does not work in the terminal (which is the only place I really need to use this symbol).

So, how can I change the keyboard mapping so that the "¦" key emits a "|" character ?

  • If you are actually using the British - PC input source provided by Apple, then the pipe symbol should indeed be located at the key you want. Are you using some other input source with the same name provide by someone else? – Tom Gewecke Oct 8 '13 at 18:26
  • as far as I know I am using the "British - PC" input source provided by Apple. – starfry Oct 9 '13 at 22:11
  • I think you need a special layout. See if any of those at this site help: liyang.hu/osx-british.xhtml – Tom Gewecke Oct 10 '13 at 4:34
2

Revisiting this four years later, now with macOS Sierra.

If you have a non-Apple keyboard then you may want to use a more appropriate keyboard mapping. You can select keyboard mappings through the keyboard tab of the System Preferences dialog. Select Input Sources and use the + button to select a mapping appropriate for your keyboard. (You may also need to use the - button to delete the mapping that you do not wish to use before your chosen mapping becomes fully effective.)

If you find the mappings provided by Apple to be unsatisfactory (Apple's British - PC keyboard does not map the pipe to the correct key - adjacent to the left-hand shift key) then you may install third-party layouts or create your own.

Here is a ZIP file containing two alternative layouts files for UK 105 key keyboards. You should unzip the files into /Library/Keyboard Layouts (use sudo).

The new layouts won't be available in the abovementioned Input Sources until you log out and back in. After that, you can select them like any other layout (they may be listed in the others category).

You can edit your chosen layout if it is still unsatisfactory (I chose the British (PC 105 alt) layout but found that Alt+3 emitted cent (¢) instead of the expected Euro (€) symbol). Layout files are simple XML text files. I identified the relevant key code and replaced its unicode output character:

<key code="21" output="&#xA2;" />

with

<key code="21" output="&#x20AC;" />

(The change was applied in two places: keymap index 3, for anyOption key (Alt to PC keyboard users), and keymap index 5 for the same with CapsLock on.)

(Once again, a log out/in cycle is required for the change to take effect).

The key code for the 4 key (which, when used with Alt should produce ) is 21. Should you wish to discover the key code for a physical key then you could use the Key Codes app, available free of charge from the Apple App Store.

Should you desire a more GUI way of customising your keyboard then you could look at Ukelele [sic] or Karabiner, formerly known as KeyRemap4MacBook (although the website states that Karabiner doesn't currently work on macOS Sierra at the moment.)


Still unresolved I wanted to identify keycodes without installing anything (think X-Windows xev) and I could not find Apple's standard key layouts (they aren't in /Library/Keyboard Layouts). I guess they are in /System/Library/Keyboard Layouts in a different format. It would be nice to be able to use a standard layout as a starting point for custom edits made as described above.

  • Regarding your "still unresolved", Ukelele provides many of the standard layouts with its download, and also has a menu item "File > New From Current Input Source." It is really a lot easier and more reliable to use its gui to make mapping changes than trying to edit the xml files. – Tom Gewecke Mar 31 '17 at 16:33
0

Edit: I didn't notice that you were already using the British - PC input source.

You can flip the ` and \ keys (§ and ` in the Mac British keyboard layout) by using a private.xml like this with KeyRemap4MacBook:

<?xml version="1.0"?>
<root>
  <item>
    <name>test</name>
    <identifier>test</identifier>
    <autogen>__KeyToKey__ KeyCode::BACKQUOTE, KeyCode::UK_SECTION</autogen>
    <autogen>__KeyToKey__ KeyCode::UK_SECTION, KeyCode::BACKQUOTE</autogen>
  </item>
</root>
  • Didn't he say that he had already selected the British - PC layout? – Tom Gewecke Oct 8 '13 at 16:50
  • I'll have a look at this. Is there not a native way to do this (i.e. without installing another app) ? – starfry Oct 9 '13 at 22:14
  • @starfry You could also create a custom keylayout file. – Lri Oct 10 '13 at 13:30
  • @Lauri -- how is it possible that the British Model M does not obey the Apple British-PC keylayout regardless of what is printed on the keys. Does it return non-standard codes? – Tom Gewecke Oct 10 '13 at 23:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .