I want something to happen when I hit the space bar. I want to do this myself, but how can I check whether the space bar has been pressed.
The best way to do this is with a scoreboard:
/ scoreboard objectives add jump jump
if the scoreboard for a player changes to 1, it means that he has jumped once.