Added simple keyboard control; reformatted code