Following Line

ok so heres my problem i want to make it so that when the person hits the arrow key it will move my object a pencil in this case and draw a line from that point how is it possible ive tried searching around and havnt been able to find anything. please help.