added some comments, moved keyboard functionality into the app object