Customizable gamepad/joystick/keyboard with an Arduino Leonardo. An explanation of how it was written is available here.
The circuit is up to you - each pin transition from
HIGH will generate the corresponding key press event,
LOW will generate the key release, with a debounce delay (50ms by default). A sample circuit is
available in Arduino samples.