I have a laptop with a broken space bar and I want to map the right alt or control keys to emit a space character. I am running Ubuntu.
xmodmap -e 'keysym Control_R = KP_Space'
this will allow you to use the left control key as a space key.
I had the same problem with a broken spacebar. This was the simplest result I found, but at first using the Alt_R option didn't work because I had followed a different tutorial and messed up the binding of my right-alt key.
To find out which keysym to use just run 'xev' and press the key that you want to remap to the spacebar function. That will give you the keysym (in my case it was 0xfe03). Then in a terminal type: xmodmap -e 'keysym [keysym you found] = KP_Space' and hit 'Enter' (don't type the brackets either, just your keysym).
You can remap more than one key in this way, for example I never use the right windows key (keysym Super_R) so I did the same for that one and now I have two adjacent keys that both act as a spacebar. Hope this helps someone else to save around 30 quid buying a new laptop keyboard like it did for me!
BIG HOWEVER! However, I just found that you will need to do this every time you login UNLESS you create a new file and add it to startup. Additionally, you will note that I am using the keycode rather than keysym. This is because the keysym could change if you or another program changes it. The keycode stays the same.