It took me awhile to remember that waitforkey does not work while the kindle is in screensaver mode. Tapping the power button while this program is running fixes that though.
In the past, waitforkey returned a keycode for rotation events even when in screensaver mode. After upgrading to 5.1.0, I see that it no longer returns rotation events. Perhaps the accelerometer defaults to OFF instead of ON as it did in 5.0.x firmware.