macOS: How do I stop iTunes from reacting to media keys?

On OS X/macOS you can remote control iTunes via the so-called media keys or controls. I.e. <<, >>, and ❙❙►.
Unfortunately, by default those keys start iTunes, which may or may not be what you want. To prevent iTunes from starting, you need to make sure the rcd (remote control daemon—yep, that's the thing that reacts to your Apple remote) does not start or is stopped.

To achieve this, you need to start the Terminal app (usually under /Applications/Utilities, but if you cannot find it, just type Terminal into Spotlight). At the prompt, enter the following two lines exactly as they appear here:

launchctl unload -w /System/Library/LaunchAgents/
launchctl stop

The first line makes sure that rcd isn't started. The second line stops it, in case it is already started.

To re-enable rcd, use the following two lines:

launchctl load -w /System/Library/LaunchAgents/
launchctl start

Starting with El Capitan, you may need to temporarily turn off SIP to disable rcd. This article explains how to do that.