glad you asked, i had a program that did this years ago.. but i dunno what i did with it and dont remember the name.
so i went looking and found this
http://www.brothersoft.com/keyboard-199795.htmlvery small, and this looks to be nicer then the one i had years ago..
writen by a guy named jason hood,
http://www.geocities.com/jadoxahis website is on geocities which is getting shut down in a few months.
looks like he has a lot of cool software but i did'nt see his keyboard program for down there for some reason.
it runs fine in winxp, i believe it's dos compatible, but i have'nt tried it out.
i've attached a copy here for convenience.
my anti virus (norton june 21st definitions) says it's clean.. but you might wanna run it as a low level user just in case.
for controllers you can go to the control panel (windows), and select gaming controllers, you'll see a list of controllers open the one you want to test by double clicking on it, you'll see all buttons and axis for it, can't test rumble feature this way but i doubt you care about that.