The kindles have a "waitforkey" command. It returns the same keycodes used by the launchpad app (and can be used to find keycodes to use in it).
On the kindle DX/K3/K4 it returns keycodes for the buttons on the sides too, in addition to the "keyboard" keys. On the Touch it also returns keycodes for touchscreen and accelerometer (rotation) events (so picking up your kindle touch can cause a script to continue when sitting at a "Press any key to continue . . ." prompt.
You can use "waitforkey" in script files. For testing a lot of keys, I like to do this from SSH:
while :;do waitforkey;done