The answer to your question depends on the type of terminal and how it is attached. If we are talking about an ASCI terminal and it is serial attached then if most keys are working ok, but some are not you have some options. If none of the keys are working right, then you probably have a hardware problem that can't be fixed.
First make sure you have the right TERM variable set.
export TERM=vt320
This should help if the problem if function keys or arrow keys.
If you have other specific keys that don't work, then there is a function called 'setmaps' that can be used to 'translate' from one set of characters to the other.
Sometimes for keys like function keys you want to see exactly what charaters are being displayed. Type
stty -echo; od -ax; stty echo
Then press the key a couple times, and then press ctrl-D until the keystrokes are shown and you have the command prompt back. Good for looking at function keys and keypad keys.
If you are using an X based terminal, then the answers are different and deal with xmodmap instead.
Good luck.