Switch to Angular.js

For simplicity and readability, this refactors the code to make it understandable.

This patch also adds a few features, like support for the enter and escape keys, and ignores the arrow keys when the input is focused.