Well...with some keyboards, it's a trivial act, actually...but they tend to be gamer-oriented keyboards like the
Logitech G15, which includes the requisite software to do just such a task.
Unless you want to buy a snazzy new keyboard, I would suggest looking into
Autohotkey, which should satisfy you.
Incidentally, the only reason
I have a G15 is that one was mistakenly placed on clearance at Best Buy for $30...and a nice USB keyboard with backlight, an LCD, macro buttons, and a built-in USB hub is hard to resist.