OS X accommodates a number of different keyboard types and layouts to support not only small and large keyboard profiles such as laptop and desktop keyboards, but also to support different language input options. The layout you are using should be automatically set up when you initially configured your system, but you can always go to the Keyboard system preferences and choose a different layout if you would like.
In addition to the options for changing your keyboard layout, the system should prompt you for configuration options when you plug a new keyboard in to your computer; however, even with all of these options there are instances where a keyboard will not be recognized properly and will either give unwanted characters when used or even have sections of the keyboard such as the keypad not be recognized.
If these problems happen, the first thing to do is determine if the problem is happening in your user account (a step that is part of a). To do this, simply log in to another user account (create one for testing purposes in the Accounts or Users & Groups system preferences if you don't have one), and then see if the keyboard works properly in that account. If so then you know the problem has to do with a configuration in your account only and is not a global issue.
Another quick option to try is replace the batteries for Bluetooth or other wireless keyboards, as this is a common reason why a wireless keyboard will stop working properly (though the system should notify you when the batteries are low).
Usually issues with keyboards are rooted in the user's account, and to tackle them first go to the user library (in Lion you will have to press the Option key and choose the Library from the Finder's "Go" menu), and then go to the Preferences folder in the Library. In this folder locate and remove the file called "com.apple.HIToolbox.plist," which is one of two preference files for "human interface" devices such as keyboards. After doing this, go to the "ByHost" directory within the preferences folder and remove all files that start with "com.apple.HIToolbox" in their names (sorting the list alphabetically will help locate these files).
With these preferences gone, simply log out and log back in, and try using the keyboard again. If the keyboard is still not working, then the last option to try with your user account is to remove the global preferences file, which contains language and input settings for your user account. To do this, open the Terminal utility and run the following command:
defaults delete -g
Another issue with keyboard configuration might be a specific hot key not working properly, or hot keys not working at all. In this case instead of removing configuration files, first try checking the Keyboard Shortcuts section of the Keyboard system preferences to see if the expected shortcut for a given function has changed. The shortcuts are categorized in the left-hand column and listed next to their respective modifier key on the right-hand column, along with a check box for enabling or disabling the shortcut.
If you cannot find your shortcut and have not created any custom ones, you can click the "Restore Defaults" button under the shortcut list to clear out any potential changes that might be causing your problem.
Sometimes the problem might not be with the shortcuts being used, but rather with the modifier key configuration of the keyboard. By default the modifier keys on the keyboard invoke their respective functions (that is, the Option key issues the "option" input to the system, and likewise for the Control, Caps Lock, and Command keys); however, OS X does support an option to change these keys around, which if done will alter how most hot keys work. To check for or adjust the modifier key assignments, go to the "Keyboard" tab of the Keyboard system preferences and click the "Modifier Keys..." button at the bottom of the window. In the resulting configuration panel you will be able to adjust your modifier key settings.
If the problem with your keyboard appears to be more global in nature, then you might try checking for any third-party input drivers or utilities you might have installed (such as those for non-Apple keyboards and mice). You can list the installed system extensions to better determine this by opening the System Profiler utility (called "System Information" in Lion) and choosing the "Extensions" section. Then scroll down to see if any of the extensions named remind you of an input management tool you might have installed, and then look into uninstalling it.
A final option for troubleshooting more global input issues is to download and install the latest Combo updater for your version of OS X, which can be found quickly by performing a google search for the version number followed by "Combo Update," such as "10.6.4 Combo Update" to get the updater for OS X Snow Leopard version 10.6.4. Download the update and apply it, and then reboot the system to see if the keyboard problems continue.