Already did exactly that with an Arduino Pro Micro (~$5 for a clone). Google "arduino keyboard" for plenty of examples.
BTW it could be a nice source of laughes, i.e. plugging your device to a victim's computer, randomly sending Ctrl + P then Enter, etc.