refactoring sendmessage and keypress functions, should next turn these into directives
Merge pull request #1 from howardjing/master

refactoring keypress and sendmessage function