1. Add a Keyboard Sensor
For this tutorial, I'm going to use python to rotate the default cube. We are going to use one keyboard sensor to turn the rotation on and one keyboard sensor to turn the rotation off.
Give each keyboard sensor a unique name. The python script needs the sensor name to find it.
Select Cube: Object mode
Buttons Window menu >> Logic (F4)
Name it: On
Key: X key