4

I am trying to define a keyboard layout for OS X (Mavericks). My goal is to distinguish left/right shifts. I have created this test layout but without luck. Both combinations left/right shift + q produces the same.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE keyboard SYSTEM "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<keyboard group="0" id="5000" name="U.S." maxout="2">
  <layouts>
    <layout first="0" last="0" modifiers="48" mapSet="312" />
  </layouts>
  <modifierMap id="48" defaultIndex="0">
    <keyMapSelect mapIndex="0">
      <modifier keys="" />
    </keyMapSelect>
    <keyMapSelect mapIndex="1">
      <modifier keys="shift" />
    </keyMapSelect>
    <keyMapSelect mapIndex="2">
      <modifier keys="rightShift" />
    </keyMapSelect>
  </modifierMap>
  <keyMapSet id="312">
    <keyMap index="0">
      <key code="12" output="q" />
    </keyMap>
    <keyMap index="1">
      <key code="12" output="1" />
    </keyMap>
    <keyMap index="2">
      <key code="12" output="2" />
    </keyMap>
  </keyMapSet>
</keyboard>
JJJ
  • 32,902
  • 20
  • 89
  • 102
Jiří Lechner
  • 750
  • 6
  • 19
  • Not a solution to your problem but, programmatically it is possible. See for example [this thread](http://stackoverflow.com/questions/10715910/is-there-a-way-to-differentiate-between-left-and-right-shift-keys-being-pressed). – mattias Nov 07 '14 at 18:01
  • Thanks, I have noticed this option. I just wonder if anyone is using keylayout with this distinction since it should be solvabel via keyboard layout but sadly doesn't work... – Jiří Lechner Nov 09 '14 at 21:36
  • I have the same problem. Shift and rightShift are both treated as anyShift it seems? It's possible to do this in Karabiner though: https://pqrs.org/osx/karabiner – Albin Jan 06 '15 at 20:43

1 Answers1

1

From my experience, it is not possible.

You are correct that in theory it should be possible to treat rightShift, rightOption and rightControl separately, but this has never worked.

The docs say:

Note that many hardware keyboards do not have both left and right versions of a modifier key. It is usually safest to specify modifers in terms of the "any" variants (anyShift, anyOption, anyControl).

However, the problem is not the hardware. Programatically, right keys can indeed be detected (e.g. using https://manytricks.com/keycodes/), but not in .keylayouts. Even if you explicitly remap a key to right_shift using Karabiner, macOS will still use your shift (= left shift) key map.

ThomasR
  • 1,067
  • 1
  • 11
  • 16