Macbook pro 15" keyboard freezes only function keys work

Solution 1:

Finally got it. I was pressing option keys lot of times and pressing it 5 times enables mouse keys (which disables keyboard keys).

To reverse, go to "Settings -> Accessibility -> Mouse and Trackpad" and uncheck "Press the option key five times to turn Mouse keys on of off" or simply uncheck "Enable Mouse Keys."