Map right-side Option to Enter in OS X

Written . Tagged OS X.

In OS X, the Enter (⌅) key does not always do the same thing as Return (↩): when editing text in Photoshop, Return breaks lines and Enter commits the changes.

Adium and Colloquy can be set up much the same way: Return breaks lines, Enter sends. TextMate makes good use of Enter in its commands.

For a while up until recently, Apple keyboards without a separate numerical keypad still had a dedicated Enter key. It has since been replaced with a right-side Option key. While this was probably a change for the better to most users, some users have gotten used to the Enter key and miss it. While you can still produce Enter with Fn+Return, this is not nearly as convenient.

I looked into other solutions but had the same experience as this blogger – the only thing that really works is some C. So here is some:

Put the opt2enter binary in /usr/local/bin.

To make sure the binary is always running in the background, put name.henriknyh.opt2enter.plist in /Library/LaunchDaemons and run this command in a Terminal:

1
sudo launchctl load -w /Library/LaunchDaemons/name.henriknyh.opt2enter.plist

The source code is available. I’m not really a C programmer, and not very familiar with these libraries. Don’t hesitate to give suggestions on improvements to the code, functional as well as aesthetic.

The application is intended to be a Universal Binary. I’m not sure whether any PPC Macs have right-side Option keys, but they can of course be used with the Apple Wireless Keyboard that does. Let me know if you try this on a PPC and it works or not. I don’t have one to try on.

There is a half-broken bonus feature: Enter is only sent if you press no other key at the same time; otherwise it still sends Option. So you can still e.g. use right-Option plus “.” for ellipsis. This is half-broken because you’ll get a line break too, after you hit Option but before you hit “.”

There are various other minor limitations. Probably nothing you’ll run into, but see the source code TODOs. And again, don’t hesitate to give suggestions on how to fix these.