Instead of

if(key_space == 1)...

use

if(key_hit("space"))...

You must include keys.c before, here is the description:

http://manual.3dgamestudio.net/keys_c.htm