Try the keyboard on another Mac or PC. If it still fails you know the keyboard is broken. You can also try the keyboard when booted into recovery mode as a basic test. That will tell you if the keyboard works OK when a simple copy of the OS is running without all your installed apps.
OS X: About OS X Recovery - Apple Support
Select the option to browse the web to try the keyboard in Safari in recovery mode.
If the device is from 2010 you should look at buying a new device, otherwise if it is new & still in warranty return it to the shop or manufacturer.