The reason for your terminal to behave this way is because it is sending keypress codes that your system does not recognize as proper codes for they keys you press (which results in either weird or no action at all).
You need to set a correct terminfo string within your terminal emulator or SSH client. This string tells the system what are capabilities of your terminal emulator/SSH client, what codes are assigned to which keys, all special sequences, etc. If this is set incorrectly, you will experience glitches like arrow keys doing weird things, arrow keys doing not what they're supposed to, lack of support for shift/alt/ctrl modifiers, lack of support for F-keys, and so on.
Unfortunately, you didn't post any additional information on what exactly you are doing, so I can't help you further. My final advice is, if you are using PuTTY to connect to a remote server - use KiTTY instead (PuTTY fork with additional features and fixed keycodes bugs) along with a KiTTY terminfo file that can be found on GitHub I made that you should install in your remote system. Please be aware that there's also a kitty terminal emulator as a native application, not a PuTTY fork.