Besides the obvious hardware issues which may arise with age or letting the keyboard get dirty to the point the keys get sticky with food drink or too much dust, lack of good connections with USB port or cable, and possible DOA keyboards, there are software issues which may make a keyboard not function as expected.
In Mac OS X up to 10.2.6 there is Apple menu -> System Preferences -> Keyboard panel where you can activate Full keyboard Access, and Mac OS X 10.2.7 and 10.2.8 an Apple menu -> System Preferences -> Keyboard and Mouse panel where you can enable the same. Test these settings to see if your input problems are being caused by that. Also if you have an Apple menu -> System Preferences -> Universal Access, find out if Keyboard Access is turned on, as that changes the functions of parts of the keyboard from their obvious defaults.
One of these issues is discussed in the Apple knowledgebase article 25553:
Apple menu -> System Preferences -> International if turned on may also cause the keyboard to switch from its default layout if you have another layout turned on.
Once eliminating potential software issues, then look at hardware issues.
Three third party software packages in older versions known to have cause keyboards to malfunction are:
Synergy and CopyPasteX and Application Enhancer
Be sure to get their latest version if you have these packages and you see unexpected erroneous input coming from your keyboard when you type using your keyboard.
If your computer's Speech recognition has ever been used, you may find that a key is mapped to only work when a certain word is spoken. To find out if it is, go to Apple menu -> System Preferences -> Speech -> Spoken User Interface -> Other Spoken Items, and select the shortcut that is mapped to the key that isn't responding correctly, and map it to a different combination of keys or remove the shortcut entirely.
If third party mouse or keyboard drivers haven't been updated, sometimes keyboard shortcuts may be disabled. Verify with the driver software developer that the one you are using was designed for your operating system. One user reported that by updating their Kensington drivers from 2.3 to 2.6 for their trackball, the command-N keyboard shortcut which had been disabled in several applications worked again. Check third party peripheral manufacturers for updates of any input peripherals you have to verify that isn't what is causing the keyboard or mouse input to fail.