Just use arrow keys and spacebar when battery gets full.
Codecraft Lab. They taught me how to do this kind of game.