What I really want to know is whether it is a hardware problem, or a software problem. Could I plug my android phone into a computer via USB and have it act as a hardware ke
I believe that you can do it if you have a rooted device with a recent Android. For example, the Asus Eee Pad Transformer running Android 4 has the libraries /system/lib/libusb.so
and /system/lib/libusbhost.so
, so you can write a Java application that calls them using JNI to emulate a USB keyboard. This means that you must write some glue C code that emulates the way a USB keyboard is communicating with a PC (=you must study the way the USB protocol works).
I say "rooted", because some permissions are usually needed to use these libraries.
Edit: The above is true when programming an Android device to act as a USB host, in your case you need to be a "gadget". I don't know how much of the Linux gadget functionality is contained in the kernel of your Android device. See this for a similar question.