Refacted some code to use constants

Specifcally BACKSPACE / ESCAPE / ENTER.
Fixed bug where backspace is not handled correctly in non-canonical
mode.

Fixes #40.