swap mapping of left and right shift keys

From your edits, it seems like the specific keyboard you're using is causing the problem. I don't know any way to fix that, unfortunately, but I thought I'd answer the original question anyway.

You can remap modifier keys in OS X from at least 10.4 through to 10.10.4 by changing a Property List (.plist) file. The file is located within ~/Library/Preferences/ByHost, and is named .GlobalPreferences.[a long identifier].plist, where each user's long identifier varies. (In the Terminal, you can just use Tab-completion to pick up the specific name of your file.)

Here are the steps to copy, convert, edit, and replace the .plist:

  1. In System Preferences > Keyboard, click "Modifier Keys" and remap at least one of the buttons (e.g. Caps Lock > Control). This will ensure that the proper section exists in the .plist, and make it easier to find.
  2. In Terminal, go to or create a directory where you'll do the work, then:

    1. cp ~/Library/Preferences/ByHost/.GlobalPreferences (then press Tab to autocomplete the unique filename)
    2. plutil -convert xml1 -o ./keys-xml.plist ./keys-binary.plist
  3. Open the converted XML file. (You can use open /Applications/TextEdit.app keys-xml.plist to launch TextEdit from the Terminal.)

  4. Locate the section in the file called "com.apple.keyboard.modifiermapping...". You should see at least one "dict" group within that section. It will actually be one entry per specific key that's been remapped, so if you remapped Control to Shift, you'd see entries remapping LeftControl to LeftShift and RightControl to RightShift.
  5. Modify the existing entry using the table below, changing the HIDKeyboardModifierMappingSrc key value to the Source key (the physical button you'll press, and the HIDKeyboardModifierMappingDst key value to the Destination key you want (the key you want to take effect).
  6. Copy the entire dict section (from <dict> to </dict>, including the key mappings, and paste one per key you want to remap, changing the Src and Dst for each.
  7. Save and close the file. Then, back in Terminal:
    1. plutil -convert binary1 -o ./keys-binary_new.plist keys-xml.plist
    2. cp ./keys-binary_new.plist ~/Library/Preferences/ByHost/.GlobalPreferences (then Tab to autocomplete)
  8. Log out and back in for the changes to take effect.

Here are the key values to use for each modifier key in the Src/Dst mapping:

+-----------------+-----------+
|    Key Name     | Key Value |
+-----------------+-----------+
| None            |        -1 |
| Caps Lock       |         0 |
| Shift (Left)    |         1 |
| Control (Left)  |         2 |
| Option (Left)   |         3 |
| Command (Left)  |         4 |
| Keypad 0        |         5 |
| Help            |         6 |
| Shift (Right)   |         9 |
| Control (Right) |        10 |
| Option (Right)  |        11 |
| Command (Right) |        12 |
| ~~Kernel Panic~~|      ~~16~|
+-----------------+-----------+

NB: Key Code 16 should typically not be used.

Source: Rewritten from http://hints.macworld.com/article.php?story=20060825072451882