Added arrow key support

Also changed the code to match some JSLint standards (but not all, as it
will require a lot of code rewriting).