You can do that with a simple accelerometer.

By "integrating" the signal, it can tell you when it's moving.
Integration is just a subtraction of a "Base" reading from the accel. reading, and adding the difference to an accumulator variable.

Compensation for "Drift" is also needed, but can just be a new "Base" reading when the object is not moving.