App for developers, that will print all input events coming to your device - all fields of KeyEvent and MotionEvent classes are displayed.
It will print events from joystick or gamepad axes and buttons, mouse hover events, and touchpad events, if you have such device.
It will also dump all events to logcat.
You may attach almost any mouse/keyboard/gamepad to your phone, if you have a proper cable, or connect Bluetooth mouse/keyboard, Android OS will recognize it.
Sources are at https://github.com/pelya/AndroidInputEventsLogger