Fix issues with chat messages
This fixes #583 (closed), chatbox deletion not always working and chatbox pasting letting you go past the length limit in some situations.
Also a bunch of code cleanup, and the ability to use the del key in the chatbox.
Edited by LJ Sonic