MacOS – Using a macbook pro keyboard for developing software. Typing square brackets and curly braces

keyboardmacbook promacos

Recently, I replaced my Windows laptop with a MacBook Pro. I'm very happy that I've made the choice to switch to OS X. It's indeed very user friendly. I've noticed that when you press a key on your keyboard longer than normal that you can choose different variants (with accents and things like that). As a student in electronics engineering I need te curly braces {} and sqaure brackets[] often. Can I change the way that the ( and ) keys work and add the square brackets and curly braces to it so they appear as an option when pressing the () keys?

Edit: (I know I can type them by using option and option and shift key, but I find the little popup menu very nice feature)…
Edit 2: If this is possible, I definitely want to add the ohm sign, and other symbols that I use on a regular base…

Best Answer

  1. Navigate to /System/Library/Input Methods/PressAndHold.app/Contents/PlugIns/PAH_Extension.appex/Contents/Resources/.
  2. Make a backup of the relevant keyboard file for your locale. In my case, this is Keyboard-en.plist or Keyboard-en_GB.plist.
  3. Add custom characters or change the characters that you wish, then save the file.
  4. Log out and back in for the changes to take effect in all apps.

For example, you can add the following:

<!-- language: xml -->

    <key>Roman-Accent-0</key>
    <dict>
        <key>Direction</key>
        <string>right</string>
        <key>Keycaps</key>
        <string>{ [</string>
        <key>Strings</key>
        <string>{ [</string>
    </dict>

Files in /System are protected by System Integrity Protection. If you wish to edit the file, you will need to disable this if you haven't done so already.

To disable System Integrity Protection, you can do the following:

  1. Boot into the Recovery HD by restarting whilst holding ⌘R.
  2. Open Terminal (from the Utilities menu).
  3. Run the following command in Terminal:

    csrutil disable
    
  4. Restart.

Disable OS X El Capitan Rootless and permit write actions to System Integrity Protection locations

You can re-enable it once you've edited the file.