A couple of times now I’ve found that the keyboard on my MacBook has stopped responding.
This wasn’t a hardware failure, it turned out it was due to ‘Mouse Keys’ being enabled.
Mouse Keys is a setting which allows you to control the mouse with the keyboard. It is accidentally enabled by pressing the Option (alt) key five times in a row.
To switch it off again press the Option (alt) key five times.
To disable it permanently go to the Universal Access preferences and un-tick ‘Press the Option key five times to turn Mouse Keys on or off‘.
System Preferences > Universal Access > Mouse & Trackpad
For more details on Mouse Keys see this Apple Support article – Unable to type while Mouse Keys is enabled in Mac OS X