Press space to put the pen down. Press the up arrow to put the pen up. Read the comments inside to understand the code.