esekeyd is an alternative to using keyboard shortcuts in Openbox, which will work even if X.Org isn't running. As noted in the Debian repositories:
ESE Key Daemon is a multimedia keyboard daemon for Linux. With the 2.6 kernel series it can also handle remote controls, as they are presented as keyboards. No kernel patch is required. It is a userspace program that pools /dev/input/event? interfaces for incoming keyboard key presses.
It is rather poorly documented, unfortunately, but I gave it a try and it does indeed work well.
It can be installed with:
sudo apt-get install esekeyd
You will then need to figure out which device file is your keyboard. There are several ways to do this, as explained on Stack Overflow, but I found the brute force method to be the best. Run:
sudo keytest /dev/input/event0
... and press a few keys. If you press your left Alt, and the program prints LEFTALT, good. If it just prints a strange character combination, or nothing at all, press Ctrl+C, change event0 to event1 and repeat. Keep going (replace event1 with event2 and so forth, if that doesn't work) until you find the input that does work. Once you do find it, remember which device file you need.
Then run:
sudo learnkeys /etc/esekeyd.conf /dev/input/eventX
... and press F12.
Now, esekeyd will create the configuration file you need. You then need to edit it with your editor of choice (mine's nano, so I'd run sudo nano /etc/esekeyd.conf).
You'll see a line like this:
#F12(press):
Delete the #, and add your desired command directly after the : (no spaces!). Your new line might look something like this:
F12(press):/home/user/test_script.sh
Then, save (it's Ctrl+O then Enter for nano).
After that, you simply need to run esekeyd with the configuration file you've just created:
sudo esekeyd /etc/esekeyd.conf /dev/input/eventX
It won't automatically start at boot, so you'll need to set that up yourself, if you need it. It's up to you how, and any of those methods should work just fine.