Function keys and Enter key on built-in keyboard of 13" rMBP mysteriously remapped. How to fix or reset to default?
First, boot into single user mode/verbose mode. If the problem persists, its hardware.

The hardware problem can be as simple as a loose connector between keyboard and logic board. I had experience with a malfunctioning trackpad on my no-retina MBP 13'. The cause was that the connector came loose and only some lines of signals were fed into the system. I don't see how the connector would come loose without external cause; I opened up/modded my MBP many many times. However, I can say that there is free space between the connector and the bottom chassis of the laptop, enough for it to become loose.

I know retina-ones are different from my MBP in config, so you should look up ifixit to see if that's the case for you. Plus, you might have warranty concerns etc that stop you from opening up the machine.