Adding bullets to my sprire

I am not being able to add bullets to my sprite. Sometimes the whole game stops working whereas sometimes the sprite won’t move. How can I add bullets to my sprite as soon as I press the SPACEbar.

Hi,
Look at this examples:


or

Use the examples. Look for errors in the browser console.